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

Date format to parts #678

Closed
rxaviers opened this issue Jan 25, 2017 · 4 comments
Closed

Date format to parts #678

rxaviers opened this issue Jan 25, 2017 · 4 comments

Comments

@rxaviers
Copy link
Member

rxaviers commented Jan 25, 2017

Context

Formatter is designed to provide an opaque string as an output that is not meant to be manipulated by the consumer, which makes impossible for UX/design using rich formatting, e.g., "May <strong>05</strong> 2014", "09:49 <i>pm</i>", and "<strong>Monday</strong>, 09/12/2015".

Goal

Expose format to parts similarly to Ecma-402 Intl.DateTimeFormat.prototype.formatToParts().

References

@rxaviers
Copy link
Member Author

Some API ideas

  1. Add option.parts to dateFormatter (and formatDate) that takes true or false (default). Downside: return different types depending on the options...
  2. Add new function pairs: dateToPartsFormatter and formatDateToParts. Downside: additional work for static compiler.
  3. Add a function on the returned formatter, e.g., dateFormatter() -> fn.toParts(). Downside: very hacky.

@rxaviers
Copy link
Member Author

For the record, @jzaefferer and I have discussed these options and we leaned towards option 2. It seems the one the fits the best for globalize in a way that keeps API simple. Suggestions and ideas are welcome...

@kborchers
Copy link
Contributor

kborchers commented Feb 24, 2017

I am by no means an expert here but reviewing the information you have provided, I would also lean toward option option 2 if that helps at all.

@rxaviers
Copy link
Member Author

Thank you @kborchers, it definitely helps.

@rxaviers rxaviers added the minor label Feb 24, 2017
@rxaviers rxaviers mentioned this issue Mar 3, 2017
23 tasks
@rxaviers rxaviers removed the minor label Mar 13, 2017
rxaviers pushed a commit to rxaviers/globalize that referenced this issue Apr 12, 2017
rxaviers added a commit to rxaviers/globalize that referenced this issue Apr 12, 2017
rxaviers added a commit to rxaviers/globalize that referenced this issue May 17, 2017
When dateToPartsFormatter was added, dateFormatter became an alias to
it. Although globalize-compiler can handle it by using
`.compileExtracts()`, it doesn't by using `.compile()` and passing
`formattersAndParsers` argument. This update fixed that.

Amends e4234a7
Ref globalizejs#678
Ref globalizejs#697
Ref globalizejs#700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants