Skip to content

Seasonal ranges, and formatting tips? #9

@bdarcus

Description

@bdarcus

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;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions