A Moment.js plugin for parsing OLE Automation dates.
Visit http://markitondemand.github.io/moment-msdate/ for more information and examples.
About OLE Automation Dates
An OLE Automation date, or "MSDate" as we call it, is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.
moment to an OA date:
This API returns a floating-point number (the OA date), so once the conversion has been made, you no longer have a
Convert an OA date to a
Wed Aug 07 2013 00:00:00 GMT-0600 (MDT)
For exact date and time (time is the value right of the decimal):
Wed Aug 07 2013 16:57:55 GMT-0600 (MDT)
By default moment.fromOADate() uses the server time as the offset to UTC a second argument can be provided that indicates the offset of the OA date to UTC in minutes.
moment.fromOADate(42754.835023148145, 360) returns
Fri Jan 20 2017 02:02:25 GMT+0000 (UTC)
For Moment formatting:
This could easily be chained together as:
moment.fromOADate(41493.706892280097000).format('MMM Do YY); //Aug 7th 13
Note: OLE Automation dates are unspecified, meaning they’re based on the local timezone by default.
Converts an OLE Automation date to a moment (baking in a timezone if one is supplied) and returns a UTC Moment object instance.
moment.fromOADateWithZone('42754.835023148145', 'America/Denver'); returns
Fri Jan 20 2017 03:02:25 GMT+0000 (UTC)
Converts a moment (with timezone) to an OLE Automation date in UTC.
Copyright © 2014 Markit On Demand, Inc.
The "moment-msdate" Moment.js plugin is licensed under the Apache License, Version 2.0.