Is there already a class that holds a date and not a time or do I have to make one? Using haxe.Date can cause issues with daylight savings time. You can’t just increment by a day by adding 24 hours, since some days are 23 hours and some are 25: See this example.
I didn’t understand your problem, because for me your example works exactly as i expected.
But there is a datetime library on haxelib: datetime (3.1.4)
Maybe you are in a different timezone than me. In East Coast US I get the following output:
11:22:23:953 Sun Nov 04 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
11:22:23:954 Sun Nov 04 2018 23:00:00 GMT-0500 (Eastern Standard Time)
datetime library allows you to increment by one day:
import datetime.DateTime;
class Main {
static function main() {
var date = DateTime.fromString("2018-11-04 00:00:00");
trace(date);
var nextDay = date + Day(1);
trace(nextDay);
}
}
Result:
$ node bin/test.js
src/Main.hx:12: 2018-11-04 00:00:00
src/Main.hx:14: 2018-11-05 00:00:00
1 Like