Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

MattTuttle
Copy link

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 MattTuttle force-pushed the dateformat branch 2 times, most recently from dfaff37 to 1ad0f4a Compare April 26, 2025 21:34
* Padding for numbers is optional by adding dash (%-*).
* Support day of the year (%j).
@MattTuttle
Copy link
Author

MattTuttle commented Apr 26, 2025

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.

@skial skial mentioned this pull request Apr 28, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants