Commit 4c0d9088 by Chavee Issariyapat

add keyword now

parent 1e5787f1
...@@ -63,8 +63,10 @@ function parse(str) { ...@@ -63,8 +63,10 @@ function parse(str) {
//console.log({match}) //console.log({match})
if (!match) { if (!match) {
return; if (str == 'now') return 0;
else return;
} }
var n = parseFloat(match[1]); var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase(); var type = (match[2] || 'ms').toLowerCase();
switch (type) { switch (type) {
......
{ {
"name": "nexpietime", "name": "nexpietime",
"version": "1.0.0", "version": "1.0.1",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
......
...@@ -76,6 +76,12 @@ describe("nexpietime", function() { ...@@ -76,6 +76,12 @@ describe("nexpietime", function() {
done(); 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) { // 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);
// 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