Provides utility functions for working with DateTime and TimeSpan.
More...
|
| static long | ToUnixTime (this DateTime date) |
| | Converts a DateTime to UTC Unix Timestamp.
|
| |
| static string | ToUnixTimeString (this DateTime date) |
| | Converts a DateTime to a string containing the UTC Unix Timestamp. If the date equals DateTime.MinValue, returns an empty string.
|
| |
| static StringBuilder | ToUnixTimeString (this DateTime date,[NotNull] StringBuilder sb) |
| | Appends a UTC Unix Timestamp to the given StringBuilder. If the date equals DateTime.MinValue, nothing is appended.
|
| |
| static DateTime | TryParseDateTime (long timestamp) |
| | Creates a DateTime from a Utc Unix Timestamp.
|
| |
| static bool | TryParseDateTime ([NotNull] string str, ref DateTime result) |
| | Tries to create a DateTime from a string containing a Utc Unix Timestamp. If the string was empty, returns false and does not affect result.
|
| |
| static string | ToSecondsString (this TimeSpan time) |
| | Converts a TimeSpan to a string containing the number of seconds. If the timestamp is zero seconds, returns an empty string.
|
| |
| static void | ToSecondsString (this TimeSpan time,[NotNull] StringBuilder sb) |
| | Serializes the given TimeSpan to the given StringBuilder, as the number of seconds.
|
| |
| static bool | TryParseTimeSpan ([NotNull] string str, out TimeSpan result) |
| | Tries to create a TimeSpan from a string containing the number of seconds. If the string was empty, returns false and sets result to TimeSpan.Zero
|
| |
| static string | ToMiniString (this TimeSpan span) |
| | Converts given TimeSpan to compact string representation.
|
| |
| static bool | TryParseMiniTimespan ([NotNull] this string text, out TimeSpan result) |
| | Attempts to parse the given string as a TimeSpan in compact representation. No exception is thrown if parsing failed.
|
| |
| static TimeSpan | ParseMiniTimespan ([NotNull] this string text) |
| | Parses the given string as a TimeSpan in compact representation. Throws exceptions on failure.
|
| |
| static string | ToCompactString (this DateTime date) |
| |
| static string | ToCompactString (this TimeSpan span) |
| |
|
| static readonly DateTime | UnixEpoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ) |
| | UTC Unix epoch (1970-01-01, 00:00:00).
|
| |
| static readonly TimeSpan | MaxTimeSpan = TimeSpan.FromDays( 9999 ) |
| | Longest reasonable value that fCraft will allow to be entered for time spans (9999 days).
|
| |
Provides utility functions for working with DateTime and TimeSpan.
| static TimeSpan fCraft.DateTimeUtil.ParseMiniTimespan |
( |
[NotNull] this string |
text | ) |
|
|
static |
Parses the given string as a TimeSpan in compact representation. Throws exceptions on failure.
- Parameters
-
- Returns
- Parsed TimeSpan.
- Exceptions
-
| ArgumentNullException | text is null. |
| OverflowException | The resulting TimeSpan is greater than TimeSpan.MaxValue. |
| FormatException | input has an invalid format. |
| static string fCraft.DateTimeUtil.ToCompactString |
( |
this DateTime |
date | ) |
|
|
static |
| static string fCraft.DateTimeUtil.ToCompactString |
( |
this TimeSpan |
span | ) |
|
|
static |
| static string fCraft.DateTimeUtil.ToMiniString |
( |
this TimeSpan |
span | ) |
|
|
static |
Converts given TimeSpan to compact string representation.
- Parameters
-
| span | Time span to present. May not be negative. |
- Returns
- A string representation of the given time span.
- Exceptions
-
| ArgumentOutOfRangeException | span is negative. |
| static string fCraft.DateTimeUtil.ToSecondsString |
( |
this TimeSpan |
time | ) |
|
|
static |
Converts a TimeSpan to a string containing the number of seconds. If the timestamp is zero seconds, returns an empty string.
| static void fCraft.DateTimeUtil.ToSecondsString |
( |
this TimeSpan |
time, |
|
|
[NotNull] StringBuilder |
sb |
|
) |
| |
|
static |
Serializes the given TimeSpan to the given StringBuilder, as the number of seconds.
- Parameters
-
| time | TimeSpan to serialize. |
| sb | StringBuilder to which time will be saved. |
- Exceptions
-
| ArgumentNullException | sb is null. |
| static long fCraft.DateTimeUtil.ToUnixTime |
( |
this DateTime |
date | ) |
|
|
static |
Converts a DateTime to UTC Unix Timestamp.
| static string fCraft.DateTimeUtil.ToUnixTimeString |
( |
this DateTime |
date | ) |
|
|
static |
Converts a DateTime to a string containing the UTC Unix Timestamp. If the date equals DateTime.MinValue, returns an empty string.
| static StringBuilder fCraft.DateTimeUtil.ToUnixTimeString |
( |
this DateTime |
date, |
|
|
[NotNull] StringBuilder |
sb |
|
) |
| |
|
static |
Appends a UTC Unix Timestamp to the given StringBuilder. If the date equals DateTime.MinValue, nothing is appended.
| static DateTime fCraft.DateTimeUtil.TryParseDateTime |
( |
long |
timestamp | ) |
|
|
static |
Creates a DateTime from a Utc Unix Timestamp.
| static bool fCraft.DateTimeUtil.TryParseDateTime |
( |
[NotNull] string |
str, |
|
|
ref DateTime |
result |
|
) |
| |
|
static |
Tries to create a DateTime from a string containing a Utc Unix Timestamp. If the string was empty, returns false and does not affect result.
| static bool fCraft.DateTimeUtil.TryParseMiniTimespan |
( |
[NotNull] this string |
text, |
|
|
out TimeSpan |
result |
|
) |
| |
|
static |
Attempts to parse the given string as a TimeSpan in compact representation. No exception is thrown if parsing failed.
- Parameters
-
| text | String to parse. |
| result | Parsed TimeSpan. Set to TimeSpan.Zero if parsing failed. |
- Returns
- True if parsing succeeded; otherwise false.
- Exceptions
-
| ArgumentNullException | text is null. |
| static bool fCraft.DateTimeUtil.TryParseTimeSpan |
( |
[NotNull] string |
str, |
|
|
out TimeSpan |
result |
|
) |
| |
|
static |
Tries to create a TimeSpan from a string containing the number of seconds. If the string was empty, returns false and sets result to TimeSpan.Zero
- Exceptions
-
| ArgumentNullException | str is null |
| readonly TimeSpan fCraft.DateTimeUtil.MaxTimeSpan = TimeSpan.FromDays( 9999 ) |
|
static |
Longest reasonable value that fCraft will allow to be entered for time spans (9999 days).
| readonly DateTime fCraft.DateTimeUtil.UnixEpoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ) |
|
static |
UTC Unix epoch (1970-01-01, 00:00:00).
The documentation for this class was generated from the following file: