Coder Social home page Coder Social logo

Comments (9)

catamphetamine avatar catamphetamine commented on September 22, 2024 1

Update: Released Intl.RelativeTimeFormat polyfill as a separate package:
https://github.com/catamphetamine/relative-time-format

from proposal-intl-relative-time.

catamphetamine avatar catamphetamine commented on September 22, 2024

Also your readme says that "polyfill is in progress".
I could provide the polyfill portion as part of my library since it's already working if you want in which case let me know.

from proposal-intl-relative-time.

catamphetamine avatar catamphetamine commented on September 22, 2024

Here's the polyfill.
The tests pass.
See if it fits.
I'm reopening this until response.

https://github.com/catamphetamine/javascript-time-ago/blob/master/source/RelativeTimeFormat.js
https://github.com/catamphetamine/javascript-time-ago/blob/master/source/RelativeTimeFormat.test.js

import JavascriptTimeAgo, { RelativeTimeFormat } from 'javascript-time-ago'
import en from 'javascript-time-ago/locale/en'

JavascriptTimeAgo.locale(en)
// Returns "2 days ago"
new RelativeTimeFormat('en').format(-2, 'day')

from proposal-intl-relative-time.

littledan avatar littledan commented on September 22, 2024

Great to hear about this polyfill! This is a great step towards helping people adopt the new API.

From the source, it looks like not all of the methods are implemented--I don't see an implementation of formatToParts, supportedLocalesOf, resolvedOptions, the type parameter, or numeric formatting options. Have you considered adding these?

from proposal-intl-relative-time.

catamphetamine avatar catamphetamine commented on September 22, 2024

from proposal-intl-relative-time.

littledan avatar littledan commented on September 22, 2024

Sorry, there aren't examples written out, but you can find descriptions of all the functions in the specification. I'll leave this bug open to remind me to improve the less formal API documentation here.

from proposal-intl-relative-time.

catamphetamine avatar catamphetamine commented on September 22, 2024

@littledan

I don't see an implementation of formatToParts, supportedLocalesOf, resolvedOptions, the type parameter, or numeric formatting options.

  • formatToParts - implemented
  • supportedLocalesOf - implemented
  • numeric="always"/"auto" - implemented
  • resolvedOptions - added a basic version of it

from proposal-intl-relative-time.

littledan avatar littledan commented on September 22, 2024

From the README, this looks great! Do you want to make a PR to add a reference to this proposal's README?

from proposal-intl-relative-time.

catamphetamine avatar catamphetamine commented on September 22, 2024

@littledan Sure #101

from proposal-intl-relative-time.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.