开发者

How to determin if a SystemTime value is in UTC

开发者 https://www.devze.com 2022-12-19 02:30 出处:网络
Is there a way to determine the timezone of a DATE data type that has been converted to a SystemTime val开发者_StackOverflowue?

Is there a way to determine the timezone of a DATE data type that has been converted to a SystemTime val开发者_StackOverflowue?

Let say a C# file using the COM lib set the value below:

someComInterface.someDateAttribute = new DateTime(somedate).ToUniversalTime();

In the COM library I want to do something like this

if(VariantTimeToSystemTime(DATE, &systm )){   
    if(st == UTC ){ 
          //do something 
    }
    else{ 
          // do something with localtime 
    }
}


According to MSDN: http://msdn.microsoft.com/en-us/library/system.datetime.kind.aspx

The DateTime kind property "gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither."

If it's local, you'll want to check the TimeOffset property.

http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消