Class TimeConverter
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class TimeConverter : Object
Properties
BaseTimeZoneData
The base time TimeZoneData. NULL if time zones are not enabled.
Declaration
public static TimeZoneData BaseTimeZoneData { get; }
Property Value
Type | Description |
---|---|
TimeZoneData |
IsInitialized
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static bool IsInitialized { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsInitializing
Is in the process of initializing time zone...
Declaration
public static bool IsInitializing { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsTimezoneEnabled
Returns true if TimeZone is enabled.
Declaration
public static bool IsTimezoneEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
MaxDate
Return the highest valid date. This DateTime has Kind = Local
Declaration
public static DateTime MaxDate { get; }
Property Value
Type | Description |
---|---|
DateTime |
MaxDateUtc
Return the highest valid date, Kind = Utc, but the Ticks value is the same as for the Local variant
Declaration
public static DateTime MaxDateUtc { get; }
Property Value
Type | Description |
---|---|
DateTime |
MinDate
Return the lowest valid date, 1.1.1970. This DateTime has Kind = Local
Declaration
public static DateTime MinDate { get; }
Property Value
Type | Description |
---|---|
DateTime |
MinDateUtc
Return the lowest valid date, 1.1.1970. This DateTime has Kind = Utc, but the Ticks value is the same as for the Local variant
Declaration
public static DateTime MinDateUtc { get; }
Property Value
Type | Description |
---|---|
DateTime |
TimeZoneData
Array of TimeZoneData
Declaration
public static TimeZoneData[] TimeZoneData { get; }
Property Value
Type | Description |
---|---|
TimeZoneData[] |
TimeZoneDataByCode
Dictionary of TimeZoneData indexed on location code
Declaration
public static Dictionary<string, TimeZoneData> TimeZoneDataByCode { get; }
Property Value
Type | Description |
---|---|
Dictionary<String, TimeZoneData> |
TimeZoneDataById
Dictionary of TimeZoneData indexed on locationID
Declaration
public static Dictionary<int, TimeZoneData> TimeZoneDataById { get; }
Property Value
Type | Description |
---|---|
Dictionary<Int32, TimeZoneData> |
YearZero
Return the datetime value that is used in the database, to represent "lowest possible date"
Declaration
public static DateTime YearZero { get; }
Property Value
Type | Description |
---|---|
DateTime |
Methods
Clear()
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static void Clear()
ConvertBaseToLocal(DateTime)
Convert from the database Base time zone to the current-context local time zone. MinValue and MaxValue will not be affected.
Declaration
public static DateTime ConvertBaseToLocal(DateTime baseTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | baseTime |
Returns
Type | Description |
---|---|
DateTime | Local time, zone determined by the current context |
ConvertBiasToMinutes(String)
Convert the time zone bias string to bias in minutes.
Declaration
public static int ConvertBiasToMinutes(string bias)
Parameters
Type | Name | Description |
---|---|---|
String | bias | Bias as string, like this: "+0230" or "-0230" |
Returns
Type | Description |
---|---|
Int32 | Bias in minutes, as int. Can be negative. |
ConvertFromBaseToUTC(DateTime)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static DateTime ConvertFromBaseToUTC(DateTime time)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time |
Returns
Type | Description |
---|---|
DateTime |
ConvertFromTimeZone(DateTime, Int32)
Convert from the given time zone to the current-context local time zone. MinValue and MaxValue will not be affected.
Declaration
public static DateTime ConvertFromTimeZone(DateTime time, int sourceTZLocation)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time | Time in destinationTZLocation time zone |
Int32 | sourceTZLocation |
Returns
Type | Description |
---|---|
DateTime | Database time |
ConvertFromUTC(DateTime, Int32)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static DateTime ConvertFromUTC(DateTime time, int destinationTZLocation)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time | |
Int32 | destinationTZLocation |
Returns
Type | Description |
---|---|
DateTime |
ConvertLocalKindToBase(DateTime)
Convert from the current-context local time zone to the database Base time zone. MinValue and MaxValue will not be affected.
Declaration
public static DateTime ConvertLocalKindToBase(DateTime localTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | localTime | Local time, zone determined by the current context |
Returns
Type | Description |
---|---|
DateTime | Base time |
ConvertLocalToBase(DateTime)
Convert from the current-context local time zone to the database Base time zone. MinValue and MaxValue will not be affected.
Declaration
public static DateTime ConvertLocalToBase(DateTime localTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | localTime | Local time, zone determined by the current context |
Returns
Type | Description |
---|---|
DateTime | Base time |
ConvertToTimeZone(DateTime, Int32)
Convert from the database time to the given time zone. MinValue and MaxValue will not be affected.
Declaration
public static DateTime ConvertToTimeZone(DateTime time, int destinationTZLocation)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time | |
Int32 | destinationTZLocation |
Returns
Type | Description |
---|---|
DateTime |
ConvertToUTC(DateTime, Int32)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static DateTime ConvertToUTC(DateTime time, int sourceTZLocation)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time | |
Int32 | sourceTZLocation |
Returns
Type | Description |
---|---|
DateTime |
DateTime2TimeTLocal(DateTime)
Convert the local-time DateTime to a local-time C time_t value. If the incoming date has Kind = Local or Kind = Unspecified, no calculations will be performed. If the incoming DateTime has Kind = Utc, it will be converted to local time according to the current time zone settings.
Declaration
public static int DateTime2TimeTLocal(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Local-time DateTime to convert from |
Returns
Type | Description |
---|---|
Int32 | Seconds since local-time January 1st, 1970 |
DateTime2TimeTUtc(DateTime)
Convert the local-time DateTime to a UTC C time_t value. If the incoming DateTime already has Kind == Utc, no conversion will occur, otherwise the proper time offset is added / subtracted. Kind = Local and Kind = Unspecified are both taken to mean
Declaration
public static int DateTime2TimeTUtc(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Local-time DateTime to convert from |
Returns
Type | Description |
---|---|
Int32 | Seconds since UTC January 1st, 1970 |
GetTimeZoneDataByCode(String)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static TimeZoneData GetTimeZoneDataByCode(string timeZoneCode)
Parameters
Type | Name | Description |
---|---|---|
String | timeZoneCode |
Returns
Type | Description |
---|---|
TimeZoneData |
GetTimeZoneDataById(Int32)
Get timeZone data for a timeZoneID
Declaration
public static TimeZoneData GetTimeZoneDataById(int timeZoneId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | timeZoneId |
Returns
Type | Description |
---|---|
TimeZoneData |
IsEdgeTime(DateTime)
Is the time close to an edge time, and consequently treat it as the edge value?
Declaration
public static bool IsEdgeTime(this DateTime time)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time |
Returns
Type | Description |
---|---|
Boolean |
SnapToEdge(DateTime)
If the time is an edge time, return DateTime Min or max value. Otherwise, return the actual time.
Declaration
public static DateTime SnapToEdge(this DateTime time)
Parameters
Type | Name | Description |
---|---|---|
DateTime | time |
Returns
Type | Description |
---|---|
DateTime |
TimeTLocal2DateTime(Int32)
Convert the time from a local-time C time_t value to local-time DateTime.
Declaration
public static DateTime TimeTLocal2DateTime(int time)
Parameters
Type | Name | Description |
---|---|---|
Int32 | time | Seconds since local-time January 1st, 1970 |
Returns
Type | Description |
---|---|
DateTime | Local-time DateTime converted to, which will have Kind = Local |
TimeTUtc2DateTime(Int32)
Convert the time from a UTC C time_t value to local-time DateTime.
Declaration
public static DateTime TimeTUtc2DateTime(int time)
Parameters
Type | Name | Description |
---|---|---|
Int32 | time | Seconds since UTC January 1st, 1970 |
Returns
Type | Description |
---|---|
DateTime | Local time DateTime converted to, which will have Kind = Local |
TryGetTimeZoneDataByCode(String, out TimeZoneData)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static bool TryGetTimeZoneDataByCode(string timeZoneCode, out TimeZoneData timeZoneData)
Parameters
Type | Name | Description |
---|---|---|
String | timeZoneCode | |
TimeZoneData | timeZoneData |
Returns
Type | Description |
---|---|
Boolean |
TryGetTimeZoneDataById(Int32, out TimeZoneData)
Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values
Declaration
public static bool TryGetTimeZoneDataById(int timeZoneId, out TimeZoneData timeZoneData)
Parameters
Type | Name | Description |
---|---|---|
Int32 | timeZoneId | |
TimeZoneData | timeZoneData |
Returns
Type | Description |
---|---|
Boolean |