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

isRelativeTimeFormat false for "now" #2

Open
pqvst opened this issue Aug 16, 2015 · 4 comments
Open

isRelativeTimeFormat false for "now" #2

pqvst opened this issue Aug 16, 2015 · 4 comments

Comments

@pqvst
Copy link

pqvst commented Aug 16, 2015

isRelativeTimeFormat should return true for "now"?

@cmaurer
Copy link
Owner

cmaurer commented Oct 20, 2015

@pqvst The test returns true. Are you saying that this should be false? Im a little confused.

Chris

        it('should return true for "now" relative time', function(done){
            should(moment().isRelativeTimeFormat('now')).eql(true);
            done();
        });

@pqvst
Copy link
Author

pqvst commented Oct 20, 2015

@cmaurer Really?

console.log(moment().isRelativeTimeFormat('now'));

returns false for me. Looking at the regex I can't see how it could possibly match 'now'.

/([-+])(\d*)(minutes|minute|min|hours|hour|days|day|weeks|week|months|month|mon|years|year|Quarters|Quarter|seconds|second|sec|s|m|h|d|M|y|Y|Q|ms|w)/

@cmaurer
Copy link
Owner

cmaurer commented Oct 20, 2015

Ok. I have a test for this and it's passing. Let me look at it tonight.

Thanks,
Chris

Sent from my iPhone

On Oct 20, 2015, at 5:27 PM, Philip Bergqvist notifications@github.com wrote:

@cmaurer Really?

console.log(moment().isRelativeTimeFormat('now'));
returns false for me. Looking at the regex I can't see how it could possibly match 'now'.

/([-+])(\d*)(minutes|minute|min|hours|hour|days|day|weeks|week|months|month|mon|years|year|Quarters|Quarter|seconds|second|sec|s|m|h|d|M|y|Y|Q|ms|w)/

Reply to this email directly or view it on GitHub.

@cmaurer
Copy link
Owner

cmaurer commented Oct 21, 2015

@pqvst So in the specific function, isRelativeTimeFormat, or relativeTime, I specifically check for now.

        moment.fn.isRelativeTimeFormat = function(relativeTimeString){
            if (relativeTimeString.trim() === 'now') {
                return true;
            }
            return relativeTimeRe.test(relativeTimeString);
        };

But that does not explain why you are getting false. Can you post a gist showing me what you are trying to do?

Thanks,
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants