Show / Hide Table of Contents

Class TimeConverter

Utility class for converting between superoffice time values (seconds after 1.1.1970) and .Net DateTime values

Inheritance
object
TimeConverter
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class TimeConverter

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
bool

IsInitializing

Is in the process of initializing time zone...

Declaration
public static bool IsInitializing { get; }
Property Value
Type Description
bool

IsTimezoneEnabled

Returns true if TimeZone is enabled.

Declaration
public static bool IsTimezoneEnabled { get; }
Property Value
Type Description
bool

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
[Obsolete("Use GetTimeZoneDataByCode", true)]
public static Dictionary<string, TimeZoneData> TimeZoneDataByCode { get; }
Property Value
Type Description
Dictionary<string, TimeZoneData>

TimeZoneDataById

Dictionary of TimeZoneData indexed on locationID

Declaration
[Obsolete("Use GetTimeZoneDataById", true)]
public static Dictionary<int, TimeZoneData> TimeZoneDataById { get; }
Property Value
Type Description
Dictionary<int, 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
int

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, int)

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

int sourceTZLocation
Returns
Type Description
DateTime

Database time

ConvertFromUTC(DateTime, int)

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
int 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, int)

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
int destinationTZLocation
Returns
Type Description
DateTime

ConvertToUTC(DateTime, int)

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
int 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
int

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
int

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(int)

Get timeZone data for a timeZoneID

Declaration
public static TimeZoneData GetTimeZoneDataById(int timeZoneId)
Parameters
Type Name Description
int 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
bool

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(int)

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
int time

Seconds since local-time January 1st, 1970

Returns
Type Description
DateTime

Local-time DateTime converted to, which will have Kind = Local

TimeTUtc2DateTime(int)

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
int 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
bool

TryGetTimeZoneDataById(int, 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
int timeZoneId
TimeZoneData timeZoneData
Returns
Type Description
bool
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top