haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Improve DateTools.format (padding and day of the year)

Open MattTuttle opened this issue 7 months ago • 1 comments

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

MattTuttle avatar Apr 26 '25 20:04 MattTuttle

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.

MattTuttle avatar Apr 26 '25 21:04 MattTuttle