-
Notifications
You must be signed in to change notification settings - Fork 603
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
Add unit formatting module #512
Conversation
updated to merge cleanly
I think I can make it work by heavily cargo-culting relative-timestamp - new patch forthcoming. |
9ad38da
to
cdb605a
Compare
(I have spaces instead of tabs in many places - will update that when this is good to merge otherwise) |
* | ||
* Format units such as seconds, minutes, days, weeks, etc. | ||
*/ | ||
Globalize.prototype.formatUnit = function( value, unit, options ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update this according to the below please. So, it's accessible via both static function (Globalize.formatUnit
) and instance method (new Globalize(locale).formatUnit
)
Globalize.formatUnit =
Globalize.prototype.formatUnit = function( ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on my local branch (commenting for my own tracking benefit)
return Globalize; | ||
|
||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space vs tabs indentation is still used here. Tabs should be used for indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra empty line in the bottom of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering why grunt jscs:source
didn't caught these...
Thanks for the great feedback - working on cleaning up this branch now :) |
* | ||
* Return all unit categories. | ||
*/ | ||
return [ "acceleration", "angle", "area", "digital", "duration", "length", "mass", "power", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in exactly one place, does that really justify a separate file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it helps to make the build easier. This could change though when the source code uses ES6.
util.assertParameterPresence( assert, "options", function( ) { | ||
Globalize.formatUnit( 1, "day" ); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually options should be optional. 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on it.
Awesome! Rebased and merged. Thx @alunny |
Published in 1.1.0-rc.4 |
Great, thanks @rxaviers! |
👏 👏 👏 |
Thanks to @sompylasar Ref #252 Ref #254 Ref #512 Ref #541
Thanks to @AhmedMustafa Ref #252 Ref #254 Ref #512 Ref #541
This is picking up @rxaviers's patch in #254 to solve #252.