【发布时间】:2014-03-02 15:22:40
【问题描述】:
我正在尝试向 QDate 对象添加日期。月份和日期已正确放入 Qdate 对象中,但年份总是读回 -4713。
这是我的代码:
int main(int argv, char *argc[])
{
// Show all my arguments to make sure they are correct
qDebug() << "\n";
for( int i = 0; i < argv ; i++)
{
qDebug() << i << ": " << argc[i] << "\n";
}
// Add the yyyy-mm-dd date into date
QDate date = QDate::fromString(argc[1],"yyyy-mm-dd");
// Check to see if the date is correct
qDebug() << "Year: " << date.year() << "\nMonth:" << date.month() << "\nDay" << date.day();
return 0;
}
这是我在终端中使用的:
./birthday "1992-01-01"
输出如下:
0 : ./birthdays
1 : 1990-01-01
Year: -4713
Month: 1
Day: 1
现在,无论我为我的年份选择什么,它总是返回 -4713。有谁知道为什么?我已经在这个问题上停留了一段时间,不明白这里发生了什么。
【问题讨论】:
-
第一个观察:argc 应该是 count 和 argv - 值,这并不重要但仍然))