-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from michael-lechner/feature/updating-from-inte…
…rnal-repository feature/updating from internal repository
- Loading branch information
Showing
8 changed files
with
242 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.settings/** | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
{ | ||
"env": { | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"airbnb" | ||
], | ||
"rules": { | ||
"camelcase": [1, { "properties": "never" }], | ||
"eol-last": 0, | ||
"quotes": [2, "single"] | ||
"brace-style": [2, "1tbs", { "allowSingleLine": true }], | ||
"object-shorthand": 0, | ||
"spaced-comment": 0, | ||
"no-invalid-this": 0, | ||
"linebreak-style": 0, | ||
"no-tabs": 0, | ||
"padded-blocks": 0, | ||
"indent": [2, "tab", { "SwitchCase": 1 }], | ||
"strict": 0, | ||
"func-names": 0, | ||
"space-before-function-paren": [2, { "anonymous": "never", "named": "never" }], | ||
"global-require": 0, | ||
"max-len": [0, 100, 4, { | ||
"ignoreUrls": true, | ||
"ignoreComments": true | ||
}], | ||
"comma-dangle": [2, "never"], | ||
"no-underscore-dangle": 0, | ||
"no-empty-function": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
.DS_Store | ||
node_modules | ||
node_modules | ||
|
||
#user preferences | ||
.vscode | ||
|
||
# Logs | ||
logs | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
{ | ||
"name": "moment-msdate", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Adds OLE Automation parsing capabilities to Moment.js", | ||
"main": "moment-msdate.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"lint": "eslint ./test ./moment-msdate.js", | ||
"mocha": "mocha --check-leaks --reporter=spec ./test", | ||
"test": "npm run lint && npm run mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -15,18 +17,40 @@ | |
"msdate", | ||
"ole-automation" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Mark Healey", | ||
"email": "" | ||
}, | ||
{ | ||
"name": "Brian Baker", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Frank Martino", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Michael Lechner", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"author": "Markit On Demand", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/markitondemand/moment-msdate/issues" | ||
}, | ||
"homepage": "https://github.com/markitondemand/moment-msdate#readme", | ||
"dependencies": { | ||
"moment": "^2.10.6" | ||
"moment": "^2.17.1", | ||
"moment-timezone": "^0.5.11" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^1.1.0", | ||
"mocha": "^2.2.5", | ||
"mocha-eslint": "^1.0.0" | ||
"eslint": "^3.13.0", | ||
"eslint-config-airbnb": "^14.0.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^3.0.2", | ||
"eslint-plugin-react": "^6.9.0", | ||
"mocha": "^3.2.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"env": { | ||
"mocha": true | ||
}, | ||
"rules":{ | ||
// assert.throws doesnt respond to lambda syntax | ||
"prefer-arrow-callback": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,126 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'), | ||
lint = require('mocha-eslint'), | ||
moment = require('../moment-msdate'); | ||
const assert = require('assert'); | ||
const moment = require('../moment-msdate'); | ||
|
||
lint(['./*.js', './test/*.js']); | ||
describe('moment-msdate: moment.fromOADate', () => { | ||
it('should convert an OLE Automation date to a moment with a 0 offset to UTC', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADate(42754.835023148145, 0); // UTC | ||
assert.equal('2017-01-19T20:02:26.000Z', date.toISOString()); | ||
}); | ||
|
||
it('should convert an OLE Automation date to a moment with a 300 minute offset to UTC', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADate(42754.835023148145, 300); // ET | ||
assert.equal('2017-01-20T01:02:26.000Z', date.toISOString()); | ||
}); | ||
|
||
it('should convert an OLE Automation date to a moment with a 360 minute offset to UTC', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADate(42754.835023148145, 360); // CT | ||
assert.equal('2017-01-20T02:02:26.000Z', date.toISOString()); | ||
}); | ||
|
||
it('should convert an OLE Automation date to a moment with a 420 minute offset to UTC', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADate(42754.835023148145, 420); // MT | ||
assert.equal('2017-01-20T03:02:26.000Z', date.toISOString()); | ||
}); | ||
}); | ||
|
||
describe('moment-msdate', function() { | ||
it('should parse an OLE Automation date int', function(done) { | ||
var date = moment.fromOADate(41493); | ||
describe('moment-msdate', () => { | ||
it('should parse an OLE Automation date int', () => { | ||
const date = moment.fromOADate(41493); | ||
assert.equal(date.toString().search('Wed Aug 07 2013 00:00:00'), 0); | ||
done(); | ||
}); | ||
|
||
it('should parse an OLE Automation date double', function(done) { | ||
var date = moment.fromOADate(41493.706892280097000); | ||
it('should parse an OLE Automation date double', () => { | ||
const date = moment.fromOADate(41493.706892280097000); | ||
assert.equal(date.toString().search('Wed Aug 07 2013 16:57:55'), 0); | ||
done(); | ||
}); | ||
|
||
it('should handle rounding quirks', function(done) { | ||
var date = moment.fromOADate(42681.501388888886); | ||
it('should handle rounding quirks', () => { | ||
const date = moment.fromOADate(42681.501388888886); | ||
assert.equal(date.toString().search('Mon Nov 07 2016 12:02:00'), 0); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should convert an empty JavaScript date to an OLE Automation date of 0', function(done) { | ||
var date = new Date(1899, 11, 30, 0, 0, 0); | ||
var oaDate = moment(date).toOADate(); | ||
describe('moment-msdate: moment.toOADate', () => { | ||
it('return an OLE automation date from a jsDate input', () => { | ||
|
||
}); | ||
}); | ||
|
||
describe('moment-msdate: moment.fn.toOADate', () => { | ||
it('should convert an empty JavaScript date to an OLE Automation date of 0', () => { | ||
const date = new Date(1899, 11, 30, 0, 0, 0); | ||
const oaDate = moment(date).toOADate(); | ||
assert.equal(oaDate, 0); | ||
done(); | ||
}); | ||
|
||
it('should convert a JavaScript date to an OLE Automation date int', function(done) { | ||
var date = new Date(2012, 9, 15); | ||
var oaDate = moment(date).toOADate(); | ||
it('should convert a JavaScript date to an OLE Automation date int', () => { | ||
const date = new Date(2012, 9, 15); | ||
const oaDate = moment(date).toOADate(); | ||
assert.equal(oaDate, 41197); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('moment-msdate: moment.fromOADateWithZone', () => { | ||
it('should convert an OLE automation date with an ET timezone to a utc moment', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADateWithZone('42754.835023148145', 'America/New_York'); | ||
assert.equal('2017-01-20T01:02:25.999Z', date.toISOString()); | ||
}); | ||
|
||
it('should convert an OLE automation date with a CT timezone to a utc moment', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADateWithZone('42754.835023148145', 'America/Chicago'); | ||
assert.equal('2017-01-20T02:02:25.999Z', date.toISOString()); | ||
}); | ||
|
||
it('should convert an OLE automation date with a MT timezone to a utc moment', () => { | ||
// 1/19/2017 8:02:26 PM | ||
const date = moment.fromOADateWithZone('42754.835023148145', 'America/Denver'); | ||
assert.equal('2017-01-20T03:02:25.999Z', date.toISOString()); | ||
}); | ||
}); | ||
|
||
describe('moment-msdate: moment.fn.toOADateWithZone', () => { | ||
it('should convert a moment with a UTC offset to a UTC OLE automation date', () => { | ||
const momentDate = moment.parseZone('2017-01-19T20:02:26.000Z'); | ||
const oaDate = momentDate.toOADateWithZone(); | ||
// 1/19/2017 8:02:26 PM | ||
assert.equal(42754.835023148145, oaDate); | ||
}); | ||
|
||
it('should convert a moment with a ET offset to a UTC OLE automation date', () => { | ||
const momentDate = moment.parseZone('2017-01-19T20:02:26-05:00'); | ||
const oaDate = momentDate.toOADateWithZone(); | ||
assert.equal(42755.04335648148, oaDate); | ||
// 1/20/2017 1:02:26 AM | ||
}); | ||
|
||
it('should convert a moment with a CT offset to a UTC OLE automation date', () => { | ||
const momentDate = moment.parseZone('2017-01-19T20:02:26-06:00'); | ||
const oaDate = momentDate.toOADateWithZone(); | ||
assert.equal(42755.085023148145, oaDate); | ||
// 1/20/2017 2:02:26 AM | ||
}); | ||
|
||
it('should convert a moment with a MT offset to a UTC OLE automation date', () => { | ||
const momentDate = moment.parseZone('2017-01-19T20:02:26-07:00'); | ||
const oaDate = momentDate.toOADateWithZone(); | ||
assert.equal(42755.12668981482, oaDate); | ||
// 1/20/2017 3:02:26 AM | ||
}); | ||
|
||
it('should convert a moment to a UTC OLE automation date if timezone (tz) is set', () => { | ||
const momentDate = moment('2017-01-19T20:02:26.000Z'); | ||
momentDate.tz('America/New_York'); | ||
const oaDate = momentDate.toOADateWithZone(); | ||
assert.equal(42754.835023148145, oaDate); | ||
// 1/19/2017 8:02:26 PM | ||
}); | ||
}); | ||
|
||
// not a real reliable way to do this because of js number precision: | ||
// it('should convert a JavaScript date to an OLE Automation date double', function(done) { | ||
// var date = new Date(2015, 7, 10, 8, 10, 10, 0); | ||
// var oaDate = moment(date).toOADate(); | ||
// assert.equal(oaDate, 42226.3403935185); | ||
// done(); | ||
// }); | ||
}); |