-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Format with a
or A
are different locally vs CI
#57
Comments
Yes, a big difference between tempo and other date libraries is that the tokens are locale aware. So if you want to force a given locale you either need to set that as your system locale, or manually specify it per function call. As for the So — how do you mark something as UTC in tempo? Well you don’t really, all native Date objects are essentially just UTC timestamps (when you console log them or interact with their methods they always show localized values for that underlying timestamp). Instead, tempo lets you create that date object (utc timestamp) by specifying the time in a given location. So yes, if you want to create the utc time, in utc you can do Hope that helps |
Yeah in my case, I'll go with the first option since I use it in a datagrid open source project and I have no clue what TZ the user is in, so the On a side note, I tried many times to migrate away from MomentJS (I tried DayJS, date-fns, Luxon)... but Tempo was the only one that really worked out of the box. The parse/format is really important in a datagrid and Tempo works amazingly well and since you guys have the same token as MomentJS, it was easy to migrate... oh and the fact that you provide an ESM build is just the cherry on top 🍒 Thanks for the great lib, I think I can close the issue since you answered all my questions. A big thanks |
Hello, I am migrating away from MomentJS (finally) to your awesome library, however I'm having some issues with the
a
orA
token. locally it shows asa.m.
(orP.M
forA
in evening) but in the CI the exact same unit tests are failing because the format outputsam
instead. Also what is a bit strange is that on the website, it shows asam
but I run my code locally it shows asa.m
.I'm looking to get consistent result (I would prefer to always get
am
and nota.m.
). I'm wondering if that difference is somehow coming from my locale setup? I'm in Canada in the Eastern TZ.For example, with the format of
'YYYY-MM-DD hh:mm:ss a'
on the website I see'2024-05-04 11:53:12 pm'
but if I run it locally I see instead'2024-05-04 11:53:12 p.m.'
, why?EDIT
Yeah after testing on MDN Intl.DateTimeFormat, the output is
a.m.
foren-CA
butam
foren-US
. Are there any I can overwrite this behavior and always have the same result?EDIT 2
ahh I found that I can pass
en-US
as 3rd argument of eitherparse()
orformat()
and now it shows theam
Different Topic (question)
Also on a different topic, in Moment they had the
.utc()
function to mark the Date as UTC to differentiate local vs UTC date time. Are there any equivalent in Tempo? Below is an example taken from Moment's websiteI found that this might work,
tzDate('2020-02-04', 'utc')
, is that the correct way to get UTC? It gives me2020-02-04T00:00:00Z
The text was updated successfully, but these errors were encountered: