LibCore: Fix off-by-one in DateTime::{create,set_time} day default arg

Just like month, the day value here is one-based. This resulted in the
following situation, which is obviously unexpected:

    Core::DateTime::create(1970); // 1970-01-00 -> 1969-12-31
This commit is contained in:
Linus Groh 2021-10-30 09:06:27 +02:00
parent e9f0ebd4bd
commit 232f54cd9b

View file

@ -29,10 +29,10 @@ public:
unsigned day_of_year() const;
bool is_leap_year() const;
void set_time(int year, int month = 1, int day = 0, int hour = 0, int minute = 0, int second = 0);
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
String to_string(const String& format = "%Y-%m-%d %H:%M:%S") const;
static DateTime create(int year, int month = 1, int day = 0, int hour = 0, int minute = 0, int second = 0);
static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
static DateTime now();
static DateTime from_timestamp(time_t);
static Optional<DateTime> parse(const String& format, const String& string);