Class DateTimeHelper
Inheritance
System.Object
DateTimeHelper
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: FixAntenna.Common.dll
Syntax
public static class DateTimeHelper
Fields
Declaration
public const string GeneralFormat = "yyyy-MM-ddTHH:mm:ss"
Field Value
Type |
Description |
System.String |
|
LocalZoneOffset
Declaration
public static readonly TimeSpan LocalZoneOffset
Field Value
Type |
Description |
System.TimeSpan |
|
Declaration
public const string MicrosecondsFormat = "yyyy-MM-ddTHH:mm:ss.ffffff"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string MillisecondsFormat = "yyyy-MM-ddTHH:mm:ss.fff"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string MinutesFormat = "yyyy-MM-ddTHH:mm"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string NanosecondsFormat = "yyyy-MM-ddTHH:mm:ss.fffffff00"
Field Value
Type |
Description |
System.String |
|
NanosecondsPerTick
Declaration
public const int NanosecondsPerTick = 100
Field Value
Type |
Description |
System.Int32 |
|
TicksPerMicrosecond
Declaration
public const int TicksPerMicrosecond = 10
Field Value
Type |
Description |
System.Int32 |
|
UtcOffset
Declaration
public static readonly TimeSpan UtcOffset
Field Value
Type |
Description |
System.TimeSpan |
|
Properties
CurrentMicroseconds
Gets number of microseconds representing current UTC time.
Declaration
public static long CurrentMicroseconds { get; }
Property Value
Type |
Description |
System.Int64 |
|
CurrentMilliseconds
Gets number of milliseconds representing current UTC time.
Declaration
public static long CurrentMilliseconds { get; }
Property Value
Type |
Description |
System.Int64 |
|
CurrentNanoseconds
Gets number of nanoseconds representing current UTC time.
Declaration
public static long CurrentNanoseconds { get; }
Property Value
Type |
Description |
System.Int64 |
|
CurrentSeconds
Gets number of seconds representing current UTC time.
Declaration
public static long CurrentSeconds { get; }
Property Value
Type |
Description |
System.Int64 |
|
CurrentTicks
Gets number of ticks representing current UTC time. One tick is 100 ns, equal to DateTime.Tick unit.
Declaration
public static long CurrentTicks { get; }
Property Value
Type |
Description |
System.Int64 |
|
Methods
FromMilliseconds(Int64)
Creates DateTime System.DateTime from amount of milliseconds (UTC).
Declaration
public static DateTime FromMilliseconds(long milliseconds)
Parameters
Type |
Name |
Description |
System.Int64 |
milliseconds |
Milliseconds passed fro
|
Returns
Type |
Description |
System.DateTime |
|
GetDate(Int32, Int32, Int32, DayOfWeek)
Get nanoseconds of last millisecond, including microseconds.
Declaration
public static DateTime GetDate(int year, int month, int weekOfMonth, DayOfWeek dayOfWeek)
Parameters
Type |
Name |
Description |
System.Int32 |
year |
|
System.Int32 |
month |
|
System.Int32 |
weekOfMonth |
|
System.DayOfWeek |
dayOfWeek |
|
Returns
Type |
Description |
System.DateTime |
Return value could be be between 0 and 999999
|
GetMicroseconds(DateTime)
Declaration
public static int GetMicroseconds(this DateTime self)
Parameters
Type |
Name |
Description |
System.DateTime |
self |
|
Returns
Type |
Description |
System.Int32 |
|
GetNanosecondsOfMillisecond(DateTimeOffset)
Get nanoseconds of last millisecond, including microseconds.
Declaration
public static int GetNanosecondsOfMillisecond(this DateTimeOffset self)
Parameters
Type |
Name |
Description |
System.DateTimeOffset |
self |
|
Returns
Type |
Description |
System.Int32 |
Return value could be be between 0 and 999999
|
GetNanosecondsOfSecond(DateTime)
Get all nanoseconds of last second, including milliseconds and microseconds.
Declaration
public static int GetNanosecondsOfSecond(this DateTime self)
Parameters
Type |
Name |
Description |
System.DateTime |
self |
|
Returns
Type |
Description |
System.Int32 |
Return value could be be between 0 and 999999999
|
GetNanosecondsOfSecond(DateTimeOffset)
Get all nanoseconds of last second, including milliseconds and microseconds.
Declaration
public static int GetNanosecondsOfSecond(this DateTimeOffset self)
Parameters
Type |
Name |
Description |
System.DateTimeOffset |
self |
|
Returns
Type |
Description |
System.Int32 |
Return value could be be between 0 and 999999999
|
GetTotalMilliseconds(TimeSpan)
Declaration
public static long GetTotalMilliseconds(this TimeSpan self)
Parameters
Type |
Name |
Description |
System.TimeSpan |
self |
|
Returns
Type |
Description |
System.Int64 |
|
GetTotalMinutes(TimeSpan)
Declaration
public static long GetTotalMinutes(this TimeSpan self)
Parameters
Type |
Name |
Description |
System.TimeSpan |
self |
|
Returns
Type |
Description |
System.Int64 |
|
GetWeekOfMonth(DateTime)
Get week of month according to the Gregorian calendar
Declaration
public static int GetWeekOfMonth(this DateTime time)
Parameters
Type |
Name |
Description |
System.DateTime |
time |
|
Returns
Type |
Description |
System.Int32 |
|
ParseZoneOffset(Byte[], Int32, Int32)
Declaration
public static TimeSpan ParseZoneOffset(byte[] buffer, int offset, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
buffer |
|
System.Int32 |
offset |
|
System.Int32 |
count |
|
Returns
Type |
Description |
System.TimeSpan |
|
ToDateTimeString(Int64, String)
Converts amount of milliseconds timestamp
to string representation using format
string.
Declaration
public static string ToDateTimeString(this long timestamp, string format)
Parameters
Type |
Name |
Description |
System.Int64 |
timestamp |
Milliseconds.
|
System.String |
format |
Format string.
|
Returns
Type |
Description |
System.String |
Returns string value of DateTime converted from number of milliseconds.
|
TotalMilliseconds(DateTime)
Gets total number of milliseconds from given DateTime value.
Declaration
public static long TotalMilliseconds(this DateTime self)
Parameters
Type |
Name |
Description |
System.DateTime |
self |
|
Returns
Type |
Description |
System.Int64 |
|
TotalMilliseconds(DateTimeOffset)
Gets total number of milliseconds from given DateTimeOffset value.
Declaration
public static long TotalMilliseconds(this DateTimeOffset self)
Parameters
Type |
Name |
Description |
System.DateTimeOffset |
self |
|
Returns
Type |
Description |
System.Int64 |
|
ToTzUniversalString(DateTime, TimestampPrecision)
Declaration
public static string ToTzUniversalString(this DateTime self, TimestampPrecision precision)
Parameters
Returns
Type |
Description |
System.String |
|
ToTzUniversalString(DateTimeOffset, TimestampPrecision)
Declaration
public static string ToTzUniversalString(this DateTimeOffset self, TimestampPrecision precision)
Parameters
Returns
Type |
Description |
System.String |
|
ToUniversalString(DateTime, TimestampPrecision)
Declaration
public static string ToUniversalString(this DateTime self, TimestampPrecision precision)
Parameters
Returns
Type |
Description |
System.String |
|
ToUniversalString(DateTimeOffset, TimestampPrecision)
Declaration
public static string ToUniversalString(this DateTimeOffset self, TimestampPrecision precision)
Parameters
Returns
Type |
Description |
System.String |
|
TryParseTimeZoneOffset(String, out TimeSpan)
Parse input string to System.TimeSpan offset from UTC.
Can use system time zone Id or try to parse strings like GMT+03:30.
Declaration
public static bool TryParseTimeZoneOffset(string timeZoneId, out TimeSpan offset)
Parameters
Type |
Name |
Description |
System.String |
timeZoneId |
Time zone Id.
|
System.TimeSpan |
offset |
Out parameter with parsed offset.
|
Returns
Type |
Description |
System.Boolean |
Returns System.TimeSpan that represents time offset from UTC for given time zone Id.
|