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

Seasonal ranges, and formatting tips? #9

Open
bdarcus opened this issue Jun 3, 2023 · 0 comments
Open

Seasonal ranges, and formatting tips? #9

bdarcus opened this issue Jun 3, 2023 · 0 comments

Comments

@bdarcus
Copy link

bdarcus commented Jun 3, 2023

Hey @cormacrelf.

While it's not formally part of the spec, thought I might suggest including this anyway, per EDTF.js.

inukshuk/edtf.js#12

Also, on a simpler note, can you show how to format the parsed dates, and maybe add it to the usage section?

I'm wanting to implement localized level 1 support in a project I'm working on, and am lost.

Here's the typescript prototype code I'm wanting to convert to Rust:

  formatDate(date: string, options: Intl.DateTimeFormatOptions): string {
    const parsedDate = edtf.default(date);
    const year = parsedDate.year.toString();
    const optKeys = Object.keys(options);
    const useYear = optKeys.includes("year") && optKeys.length === 1;
    const formattedDate = useYear
      ? year
      : edtf.format(parsedDate, "en-US", options);
    return formattedDate;
  }
@bdarcus bdarcus changed the title Seasonal ranges? Seasonal ranges, and formatting tips? Jun 3, 2023
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

No branches or pull requests

1 participant