Repository navigation
Add now option to format - #27
Conversation
|
Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! 😄 |
|
CLA is valid! |
There was a problem hiding this comment.
This will not pass when now is 0, which is a valid value.
There was a problem hiding this comment.
I think that if options.now has a value other than undefined, then we should throw if that value is not finite, just like we do for date.
|
This should behave the following ways for these
Another interesting case is what happens when the var relativeFormat = new IntlRelativeFormat('en');
var output = relativeFormat.format(undefined, {options.now: 0});
console.log(output); // => "now"So the algorithm would be, first figure out the |
There was a problem hiding this comment.
The following needs to be valid, but in the current code will throw.
relativeFormat.format(new Date(), {now: undefined});Change to:
var now = options && options.now !== undefined ? options.now : dateNow();|
OK, those conditions sound right to me. I just pushed a commit around the same time you left that comment. I think it passes all those criteria but I'll go back and add some tests. |
|
@jbaudanza sounds good, and thanks for doing this! I left one more comment here: #27 (comment) |
|
OK. thanks for the good feedback. LMK if you want me to rebase or leave the history intact. |
|
@jbaudanza looks good to me, let's keep the history, it tells the important story of how we want to handle date/timestamp values. I'll merge this in tonight or tomorrow morning and update the docs, etc. This will be in |
|
no problem. happy to help! |
|
👍 |
This PR allows the caller to specify a custom value for
now.This implements the solution discussed in #26