haxe
haxe copied to clipboard
Improve DateTools.format (padding and day of the year)
Padding for numbers is optional by adding dash (%-*).
DateTools.format(new Date(2025, 1, 2, 0, 0, 0), "%-d/%-m"); // removes leading zero from day and month
Support day of the year (%j).
DateTools.format(Date.now(), "%j"); // returns the day of the year
Date.getTime() returns a different value on Lua, Python, and PHP apparently. I had to increment the day by one on those targets.
There's also some inconsistencies on Windows and Mac (Date.getFullYear) with PHP and Neko. I'm not sure how you want to handle those.