コード例 #1
0
 /// <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));
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #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());
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #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());
 }
コード例 #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)));
 }
コード例 #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)));
 }
コード例 #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)));
 }
コード例 #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)));
 }