Skip to content
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

Allow passing arguments to std/datetime/format() #4284

Closed
paul-greenweb opened this issue Feb 7, 2024 · 0 comments · Fixed by #4285
Closed

Allow passing arguments to std/datetime/format() #4284

paul-greenweb opened this issue Feb 7, 2024 · 0 comments · Fixed by #4285
Labels
PR welcome A pull request for this issue would be welcome

Comments

@paul-greenweb
Copy link

Is your feature request related to a problem? Please describe.

The problem is, it seems that the current implementation of datetime/format() doesn't allow to return a date in UTC. It is an important feature for logging purposes.

Describe the solution you'd like

I would like to be able to pass an options object to the formatter.format() function

export function format(date: Date, formatString: string, **options**): string {
  const formatter = new DateTimeFormatter(formatString);
  return formatter.format(date, **options**);
}

Code : https://deno.land/std@0.214.0/datetime/format.ts?source=#L27

I see that the options.timeZone is already implemented in formatter.format()

format(date: Date, options: Options = {}): string {
    let string = "";

    const utc = options.timeZone === "UTC";

Code : https://deno.land/std@0.214.0/datetime/_common.ts?source#L259

Describe alternatives you've considered

I didn't find an easy solution

@iuioiua iuioiua added the PR welcome A pull request for this issue would be welcome label Feb 7, 2024
@kt3k kt3k closed this as completed in #4285 Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR welcome A pull request for this issue would be welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants