summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-30 09:06:27 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-30 10:15:49 +0200
commit232f54cd9b2e166d098d12b3457e6bbdf01c7e61 (patch)
treed4cb983aeca4976a138ad75b3b9aa35ebdce9f99
parente9f0ebd4bd972e3d3082e494cbe17c45cb7ed8b4 (diff)
downloadserenity-232f54cd9b2e166d098d12b3457e6bbdf01c7e61.zip
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
-rw-r--r--Userland/Libraries/LibCore/DateTime.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/DateTime.h b/Userland/Libraries/LibCore/DateTime.h
index 46b6014ade..1e24751038 100644
--- a/Userland/Libraries/LibCore/DateTime.h
+++ b/Userland/Libraries/LibCore/DateTime.h
@@ -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);