8000 Better support for quantity of minute/hour/day/month/year, etc · Issue #243 · moment/moment · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Better support for quantity of minute/hour/day/month/year, etc #243

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.

< 8000 p class="mt-4 color-fg-muted text-center">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

Closed
hinrik opened this issue Mar 30, 2012 · 4 comments
Closed

Better support for quantity of minute/hour/day/month/year, etc #243

hinrik opened this issue Mar 30, 2012 · 4 comments
Labels

Comments

@hinrik
Copy link
Contributor
hinrik commented Mar 30, 2012

This library only uses the singular form of minute/hour/day/month/year when the quantity is exactly 1. However, in Icelandic, the singular form is used with any number that ends in 1, except when it ends in 11 (this is analogous to the written/spoken form: "one, eleven, twenty-one, thirty-one"):

1 dag
2 daga
3 daga
...
11 daga
...
19 daga
21 dag
22 daga
...
31 dag
32 daga

Could you add support for this?

@rockymeza
Copy link
Contributor

@hinrik, it sounds like you are writing an Icelandic language definition. Would it be possible for you to write one and add it in a pull request first, so that then we can add the functionality to adapt to Icelandic?

@hinrik
Copy link
Contributor Author
hinrik commented Mar 31, 2012

#246

@timrwood
Copy link
Member
timrwood commented Apr 1, 2012

All of the formatting tokens for relative time can be callback functions. So you can change this line https://github.com/hinrik/moment/commit/90056dcfa9e577114bc8710316de89114944c428#L0R34 to something like this.

dd : function(number, withoutSuffix, key) {
    return (number % 10 === 1 && number !== 11) ? '%d daga' : '%d dag';
}

Some of the languages have pretty gnarly callback functions already.

https://github.com/timrwood/moment/blob/master/lang/ru.js
https://github.com/timrwood/moment/blob/master/lang/pl.js
https://github.com/timrwood/moment/blob/master/lang/fi.js

Check out the docs on the function callback signature here. http://momentjs.com/docs/#/customization/relative-time/

Note: We will be adding an 'isFuture' parameter to the callback signature in the next release. Check out this comment. #218 (comment)

@hinrik
Copy link
Contributor Author
hinrik commented Apr 2, 2012

Noted and implemented in #246.

@hinrik hinrik closed this as completed Apr 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
0