Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alunny committed Oct 2, 2012
0 parents commit 78959ae
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function DosTime(input) {
if (typeof input == 'number') {
this.hour = (input >> 11);
this.minutes = ((input >> 5) & 0x3F);
this.seconds = (input & 0x1F) * 2;
}
}

function DosDate(input) {
if (typeof input == 'number') {
this.year = (input >> 9) + 1980;
this.month = ((input >> 5) & 0xF);
this.day = (input & 0x1F);
}
}

module.exports = {
time: DosTime,
date: DosDate
}
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "dos-clock",
"version": "0.0.0",
"description": "work with MS-DOS dates and times",
"main": "index.js",
"scripts": {
"test": "node test.js"
},
"repository": "",
"keywords": [
"dos",
"date",
"time"
],
"author": "alunny",
"license": "BSD"
}
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var assert = require('assert'),
clock = require('./index');

var numberDate = new clock.date(16649); // august 9, 2012

assert.equal(numberDate.year, 2012);
assert.equal(numberDate.month, 8);
assert.equal(numberDate.day, 9);

var numberTime = new clock.time(23911); // 11:43:14

assert.equal(numberTime.hour, 11);
assert.equal(numberTime.minutes, 43);
assert.equal(numberTime.seconds, 14);

0 comments on commit 78959ae

Please sign in to comment.