Adds OLE Automation parsing capabilities to Moment.js
npm install moment-msdateDateTime.ToOADate and DateTime.FromOADate).
moment:
moment.fromOADate(42298.6868055556) returns 2015-10-21T16:29:00.000Z
moment in UTC time
moment.fromOADate(42298.6868055556, 240) returns 2015-10-21T20:29:00.000Z
moment.fromOADate(42298.6868055556, 'America/New_York') returns 2015-10-21T20:29:00.000Z
$3
Convert a moment to a floating point OA date in UTC:
`
const momentDate = moment('2015-10-21T16:29:00.000-07:00')
momentDate.toOADate() returns 42298.978472222225
`
$3
Convert OA date into Moment (OA Date is assumed to be in UTC)
`
const momentDate = moment.fromOADate(42298.6868055556);
`
If OA date is not in UTC and the offset to UTC is known it can be specified during the moment creation in minutes
`
const momentDate = moment.fromOADate(42298.6868055556, 240)
momentDate.toISOString() returns '2015-10-21T20:29:00.000Z' (UTC)
momentDate.format('LLLL') returns 'Wednesday, October 21, 2015 8:29 PM' (UTC)
`
If OA date is not in UTC and the offset to UTC is known it can be specified during the moment creation as a timezone
`
const momentDate = moment.fromOADate(42298.6868055556, 'America/New_York')
momentDate.toISOString() returns '2015-10-21T20:29:00.000Z' (UTC)
momentDate.format('LLLL') returns 'Wednesday, October 21, 2015 8:29 PM' (UTC)
`
Once the date is in UTC it can than easily be converted to any other timezone using moment-timezone.js
`
const momentDate = moment.fromOADate(42298.6868055556, 240)
momentDate.tz('America/New_York')
momentDate.toISOString() returns '2015-10-21T20:29:00.000Z' (UTC)
momentDate.format('LLLL') returns 'Wednesday, October 21, 2015 4:29 PM' (ET)
``