如何将 OLE Automation 跨度转换为 TimeSpan 或秒数?
How to convert OLE Automation span to TimeSpan or seconds?
我的 OLE 自动化时间跨度为 double
个单位。我想将它转换成秒或 TimeSpan
对象。我在TimeSpan
或DateTime
类中搜索了相关函数,但没有找到。
如果您有一个 OLE 自动化开始日期并且 end-dates 您应该能够通过调用 DateTime.FromOADate 并取两个值之间的差值将其转换为时间跨度。
如果您只有一个值,这听起来像是有人在滥用数据类型来表示时间跨度而不是日期。我不熟悉 OLE 自动化,但文档指出:
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.
所以我假设您应该能够调用 TimeSpan.FromDays(...) 来生成时间跨度。
有了时间跨度后,如果需要秒数,您可以使用 TotalSeconds
属性。
我的 OLE 自动化时间跨度为 double
个单位。我想将它转换成秒或 TimeSpan
对象。我在TimeSpan
或DateTime
类中搜索了相关函数,但没有找到。
如果您有一个 OLE 自动化开始日期并且 end-dates 您应该能够通过调用 DateTime.FromOADate 并取两个值之间的差值将其转换为时间跨度。
如果您只有一个值,这听起来像是有人在滥用数据类型来表示时间跨度而不是日期。我不熟悉 OLE 自动化,但文档指出:
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.
所以我假设您应该能够调用 TimeSpan.FromDays(...) 来生成时间跨度。
有了时间跨度后,如果需要秒数,您可以使用 TotalSeconds
属性。