我必须为外部应用程序创建一个 xml 文件我没有文件结构的描述,所以我必须通过逆向工程来创建它。原始所需文件具有属性
LastChange = "43061.2997590394"
我认为这是特殊日期时间格式的结果。
DateTime.Parse("43061.2997590394")
抛出异常。
有人知道这是什么格式吗?
最佳答案
double oaValue = double.Parse("43061.2997590394", CultureInfo.InvariantCulture);
DateTime dt = DateTime.FromOADate( oaValue ); // Result: 11/22/2017 07:11:39
来自 MSDN 的评论:
An OLE Automation date 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.
The base OLE Automation Date is midnight, 30 December 1899. The minimum OLE Automation date is midnight, 1 January 0100. The maximum OLE Automation Date is the same as DateTime.MaxValue, the last moment of 31 December 9999.
关于c# - 特殊日期时间格式为字符串,看起来像 double,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47830513/