Skip to content

Commit

Permalink
Support input of date using dd-mm-yyyy format; Always use four digits…
Browse files Browse the repository at this point in the history
… for year in date (e.g. "0064-07-18" instead of "64-07-18")
  • Loading branch information
hanna-kn committed Jan 4, 2025
1 parent adaf74d commit c06210b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libqalculate/QalculateDateTime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ bool QalculateDateTime::set(string str) {
#ifndef _WIN32
}
#endif
} else if(newyear <= 31 && newyear > 0 && newday > 999 && newmonth <= 12) {
long int y = newday;
newday = newyear;
newyear = y;
}
if(!set(newyear, newmonth, newday)) return false;
if(b_t) {
Expand All @@ -521,7 +525,16 @@ void QalculateDateTime::set(const QalculateDateTime &date) {
b_time = date.timeIsSet();
}
string QalculateDateTime::toISOString() const {
string str = i2s(i_year);
string str;
long int y = i_year;
if(y < 0) {
y = -y;
str += "-";
}
if(y < 10) str += "0";
if(y < 100) str += "0";
if(y < 1000) str += "0";
str += i2s(y);
str += "-";
if(i_month < 10) {
str += "0";
Expand Down

0 comments on commit c06210b

Please sign in to comment.