Skip to content

Commit

Permalink
year as 12 x month
Browse files Browse the repository at this point in the history
  • Loading branch information
E.Azer Koçulu committed Oct 27, 2013
1 parent d888281 commit 2ca1df6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/units.js
Expand Up @@ -3,7 +3,8 @@ var seconds = x(milliseconds, 1000),
hours = x(minutes, 60),
days = x(hours, 24),
weeks = x(days, 7),
months = x(days, 31);
months = x(days, 31),
years = x(months, 12);

module.exports = {
m: milliseconds,
Expand Down Expand Up @@ -50,10 +51,6 @@ function milliseconds (n){
return n;
}

function years (n) {
return n * days(365) + hours(6);
}

function x (fn, multiples){
return function(n){
return fn(n) * multiples;
Expand Down
4 changes: 2 additions & 2 deletions test.js
Expand Up @@ -16,8 +16,8 @@ it('converts time written in english to epoch', function(){
expect(time('3 weeks, 5 days, 6 hours')).to.equal(2268000000);
expect(time('a month')).to.equal(2678400000);
expect(time('5 months')).to.equal(13392000000);
expect(time('one year')).to.equal(31557600000);
expect(time('one year and five months')).to.equal(31557600000 + 13392000000);
expect(time('one year')).to.equal(32140800000);
expect(time('one year and five months')).to.equal(32140800000 + 13392000000);
});

it('ignores unrecognized patterns', function(){
Expand Down

0 comments on commit 2ca1df6

Please sign in to comment.