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

Formatter does not handle [$-F800] and [$-F400] #43

Open
borgar opened this issue Jul 6, 2023 · 1 comment
Open

Formatter does not handle [$-F800] and [$-F400] #43

borgar opened this issue Jul 6, 2023 · 1 comment

Comments

@borgar
Copy link
Owner

borgar commented Jul 6, 2023

Excel has (at least) two special locales that mean "use system default":

  • [$-F800] or [$-x-sysdate]
  • [$-F400] or [$-x-systime]

By default the formatter should probably ignore these, because it has no knowledge of what the system default formats are. At the very least, it should be using the provided locale if this modifier is set.

Settings could be added so that the caller can simply define what format to use instead of ignoring it:

numfmt("[$-F800]yyyy-mmm-dd", {
  sysdate: "dddd, mmmm dd, yyyy",
  systime: "hh:mm:ss",
  locale: "fi"
});
@borgar
Copy link
Owner Author

borgar commented Oct 2, 2024

Unsolved issue with this idea is whether the sysdate/systime options should have restrictions, or if they should allow full patterns?

Allowing full patterns means we need to take care to ignore locale directives in the pattern. The following must not loop:

numfmt("[$-F800]yyyy-mmm-dd", {
  sysdate: "[$-F800]dddd, mmmm dd, yyyy",
});

It would also be preferable if things like [>1234]yyyy;dddd were not allowed in the pattern. But what about setting calendars and digit systems? It may make sense to do this:

numfmt("[$-F800]yyyy-mmm-dd", {
  // Thai digits, calendar, and language:
  sysdate: "[$-0D07041E]dddd, mmmm dd, yyyy",
});

Seems like the most sensible thing to do is parse the options but restrict the pattern to:

  • Must have only 1 section
  • Must be a date
  • Must not have a condition
  • Locale must not be F800 or F400

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