/// <summary>
 /// Gets the week number of <paramref name="date"/> according to the <strong>ISO 8601</strong> specification.
 /// </summary>
 /// <param name="date">The date.</param>
 /// <returns>The <strong>ISO 8601</strong> week number.</returns>
 /// <see>
 ///     <cref>https://en.wikipedia.org/wiki/ISO_8601</cref>
 /// </see>
 public static int GetIso8601WeekNumber(DateTimeOffset date)
 {
     return(TimeUtils.GetIso8601WeekNumber(date));
 }
Exemple #2
0
 /// <summary>
 /// Returns an instance of <see cref="DateTime"/> based on the amount of seconds since the start of the Unix
 /// epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <param name="timestamp">The Unix timestamp specified in seconds.</param>
 /// <returns>The timestamp as an instance of <see cref="DateTime"/>.</returns>
 public static DateTime GetDateTimeFromUnixTime(string timestamp)
 {
     return(TimeUtils.GetDateTimeFromUnixTime(timestamp));
 }
Exemple #3
0
 /// <summary>
 /// Returns an instance of <see cref="DateTimeOffset"/> based on the amount of seconds since the start of the
 /// Unix epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <param name="timestamp">The Unix timestamp specified in seconds.</param>
 /// <returns>The timestamp as an instance of <see cref="DateTimeOffset"/>.</returns>
 public static DateTimeOffset GetDateTimeOffsetFromUnixTime(long timestamp)
 {
     return(TimeUtils.GetDateTimeOffsetFromUnixTime(timestamp));
 }
Exemple #4
0
 /// <summary>
 /// Returns the Unix timestamp for the specified <c>date</c>. The Unix timestamp is defined as the amount
 /// of seconds since the start of the Unix epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <param name="date">The isntance of <see cref="DateTimeOffset"/> the timestamp should be based on.</param>
 /// <returns>An instance of <see cref="System.Double"/> representing the Unix timestamp.</returns>
 public static double GetUnixTimeFromDateTimeOffsetAsDouble(DateTimeOffset date)
 {
     return(TimeUtils.GetUnixTimeFromDateTimeOffsetAsDouble(date));
 }
Exemple #5
0
 /// <summary>
 /// Returns the current Unix timestamp which is defined as the amount of seconds since the start of the Unix
 /// epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <returns>An instance of <see cref="System.Double"/> representing the current Unix timestamp.</returns>
 public static double GetCurrentUnixTimestampAsDouble()
 {
     return(TimeUtils.GetCurrentUnixTimestampAsDouble());
 }
Exemple #6
0
 /// <summary>
 /// Returns the Unix timestamp for the specified <c>date</c>. The Unix timestamp is defined as the amount
 /// of seconds since the start of the Unix epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <param name="date">The isntance of <see cref="DateTime"/> the timestamp should be based on.</param>
 /// <returns>An instance of <see cref="System.Int32"/> representing the Unix timestamp.</returns>
 public static int GetUnixTimeFromDateTime(DateTime date)
 {
     return(TimeUtils.GetUnixTimeFromDateTime(date));
 }
Exemple #7
0
 /// <summary>
 /// Returns the Unix timestamp for the specified <c>date</c>. The Unix timestamp is defined as the amount
 /// of seconds since the start of the Unix epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <param name="date">The isntance of <see cref="DateTimeOffset"/> the timestamp should be based on.</param>
 /// <returns>An instance of <see cref="System.Int32"/> representing the Unix timestamp.</returns>
 public static int GetUnixTimeFromDateTimeOffset(DateTimeOffset date)
 {
     return(TimeUtils.GetUnixTimeFromDateTimeOffset(date));
 }
Exemple #8
0
 /// <summary>
 /// Returns the current Unix timestamp which is defined as the amount of seconds since the start of the Unix
 /// epoch - that is <c>1st of January, 1970 - 00:00:00 GMT</c>.
 /// </summary>
 /// <returns>An instance of <see cref="System.Int32"/> representing the current Unix timestamp.</returns>
 public static int GetCurrentUnixTimestamp()
 {
     return(TimeUtils.GetCurrentUnixTimestamp());
 }
Exemple #9
0
 /// <summary>
 /// Convert the specified <strong>RFC 2822</strong> string to an instance of <see cref="EssentialsTime"/>.
 /// </summary>
 /// <param name="str">The <strong>RFC 2822</strong> string to be converted.</param>
 /// <returns>An instance of <see cref="EssentialsTime"/>.</returns>
 public static EssentialsTime FromRfc2822(string str)
 {
     return(new EssentialsTime(TimeUtils.Rfc822ToDateTimeOffset(str)));
 }
Exemple #10
0
 /// <summary>
 /// Gets an instance of <see cref="EssentialsTime"/> representing the start of the specified <strong>ISO 8601</strong> <paramref name="week"/>.
 /// </summary>
 /// <param name="year">The <strong>ISO 8601</strong> year of the week.</param>
 /// <param name="week">The <strong>ISO 8601</strong> week number.</param>
 /// <param name="offset">The offset to convert the <see cref="EssentialsTime"/> value to.</param>
 /// <returns>An instance of <see cref="EssentialsTime"/>.</returns>
 public static EssentialsTime FromIso8601Week(int year, int week, TimeSpan offset)
 {
     return(new EssentialsTime(TimeUtils.GetDateTimeOffsetFromIso8601Week(year, week, offset)));
 }
Exemple #11
0
 /// <summary>
 /// Convert the specified <strong>ISO 8601</strong> string to an instance of <see cref="EssentialsTime"/>.
 /// </summary>
 /// <param name="value">The <strong>ISO 8601</strong> string to be converted.</param>
 /// <returns>An instance of <see cref="EssentialsTime"/>.</returns>
 public static EssentialsTime FromIso8601(string value)
 {
     return(new EssentialsTime(TimeUtils.Iso8601ToDateTimeOffset(value)));
 }
Exemple #12
0
 /// <summary>
 /// Initialize a new instance from the specified UNIX timestamp.
 /// </summary>
 /// <param name="timestamp">The UNIX timestamp specified in seconds.</param>
 /// <returns>An instance of <see cref="EssentialsDateTime"/>.</returns>
 public static EssentialsTime FromUnixTimestamp(double timestamp)
 {
     return(new EssentialsTime(TimeUtils.GetDateTimeOffsetFromUnixTime(timestamp)));
 }