ILocaleService
Members
Namespace: ASPSecurityKit
Assembly: ASPSecurityKit.dll
Summary
Provides an interface to implement user specific locale for both formatting and converting time in user time zone.
Properties
CurrentCulture
Summary
Gets the CultureInfo object for the current thread.
Value
The CultureInfo object for the current thread.
TimeZone
Summary
Gets or sets the TimeZoneInfo object associated with this locale service instance. It could be null if no specific timezone is being used.
Value
the TimeZoneInfo object associated with this locale service instance. It could be null if no specific timezone is being used.
Now
Summary
Gets a DateTime object that is set to the current date and time on this computer, expressed as the TimeZone
Value
a DateTime object that is set to the current date and time on this computer, expressed as the TimeZone
UtcNow
Summary
Gets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).
Value
a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).
Methods
Set(cultureCode,timeZoneId)
Summary
Sets culture and time zone information for this instance. Call this method upon authentication, for example, to initialize identity specific locale for the request.
Parameters
Name | Type | Description |
---|---|---|
cultureCode | System.String | A valid culture code value. |
timeZoneId | System.String | Optional. A valid time zone identifier. |
Exceptions
Type | Description |
---|---|
System.ArgumentNullException | When culture code is null or whitespace. |
Remarks
A CultureInfo object is created based on cultureCode
, and both CurrentCulture and CurrentUICulture are set to this object for the current thread.
If the value of timeZoneId
is not specified or no TimeZoneInfo could be found for that value, the property TimeZone value is set to null
.
ToUserDateTime(utc)
Summary
Converts the value of utc
into local time using TimeZone.
Returns
A DateTime object that is converted to user local time using TimeZone.
Parameters
Name | Type | Description |
---|---|---|
utc | System.DateTime | The DateTime object expressed as the coordinate universal time (utc), to be converted to user local time. |
Remarks
If utc
Kind = unspecified, it is assumed to be utc.
FromUserDateTime(local)
Summary
Converts the value of local
into UTC time using TimeZone.
Returns
A DateTime object that is converted to coordinate universal time (UTC) using TimeZone.
Parameters
Name | Type | Description |
---|---|---|
local | System.DateTime | The DateTime object expressed as local time (regardless of the value of Kind property, the time is considered as if it’s expressed in TimeZone). |
Remarks
Regardless of the value of local
Kind property, the time is considered as if it’s expressed in TimeZone.
If TimeZone isn’t set, function simply returns value obtained by calling ToUniversalTime on local
.