-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
The date plugin should support specifying a timezone #391
Comments
The only way I know to set a timezone that works consistently everywhere (not only with This is what I use in the task for tests: https://github.com/lumeland/lume/blob/master/deno.json#L4 So I recommend to edit your lume task to include this environment variable with your timezone of choice. It might be configurable in the |
In my (WIP) blog I'm using I framed this issue specifically about date formatting because of that, but if you think any such options should also apply to date parsing, that's fine. I can define a custom |
Yeah, I think temporal should make things more easy. If you find a simple way to have this in the |
I recommend switching to dayjs (repo). It's smaller, and its many plugins include a timezone plugin. I did some tests. I used esbuild to bundle & minify the following code, with tree-shaking enabled. Here are the results. date-fns: export { format } from "npm:[email protected]"; dayjs: import dayjs from 'npm:[email protected]';
// Timezone plugin depends on this
import utc from 'npm:[email protected]/plugin/utc.js';
import timezone from 'npm:[email protected]/plugin/timezone.js';
dayjs.extend(utc);
dayjs.extend(timezone);
export default dayjs; |
@binyamin dayjs looks nice but the available formats are different from date-fns: dayjs vs date-fns, so it would break things. I'd rather to wait until I can switch to something more standard like the Temporal API or even the Intl API that doesn't require any external dependency and it's already supported by Deno (but it's buggy in my native language, Galician, so I cannot use it for now). |
Temporal API is stable in Deno 1.40 now: https://deno.com/blog/v1.40 :) |
It's not stable yet, it requires the |
Ah, I misread. Sorry. |
Enter your suggestions in details:
Currently, the date plugin uses the system's default timezone. This can result in a difference between local testing and deployment, if the build for deployment uses CI (Github Actions uses the UTC timezone, for example, although this is configurable).
The timezone to use should be able to be set in the plugin's options, but it would also be nice to have a format that will display a date as with
Date.prototype.toISOString
. This is equivalent todate("ATOM")
in a UTC timezone, but sincetoISOString
is a standard, it would be useful to also make it available regardless of the timezone set in the plugin options.The text was updated successfully, but these errors were encountered: