Commit 4c0d9088 by Chavee Issariyapat

add keyword now

parent 1e5787f1
......@@ -63,8 +63,10 @@ function parse(str) {
//console.log({match})
if (!match) {
return;
if (str == 'now') return 0;
else return;
}
var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase();
switch (type) {
......
{
"name": "nexpietime",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
......
......@@ -76,6 +76,12 @@ describe("nexpietime", function() {
done();
});
it("should accept now as the crrent time", function(done) {
expect(nexpietime.parse('now')).to.equal(Date.now() );
done();
});
// it("should accept relative time string 1month as 1 month ago", function(done) {
// expect(nexpietime.parse('1month')).to.equal(Date.now() - 24*60*60*1000);
// expect(nexpietime.parse('-1month')).to.equal(Date.now() - 24*60*60*1000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment