wasSharp – Diff between revs 18 and 27

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 18 Rev 27
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6   6  
7 using System; 7 using System;
8   8  
9 namespace wasSharp.Timers.Utilities 9 namespace wasSharp.Timers.Utilities
10 { 10 {
11 public static class TimeExtensions 11 public static class TimeExtensions
12 { 12 {
13 /// <summary> 13 /// <summary>
14 /// Convert an Unix timestamp to a DateTime structure. 14 /// Convert an Unix timestamp to a DateTime structure.
15 /// </summary> 15 /// </summary>
16 /// <param name="unixTimestamp">the Unix timestamp to convert</param> 16 /// <param name="unixTimestamp">the Unix timestamp to convert</param>
17 /// <returns>the DateTime structure</returns> 17 /// <returns>the DateTime structure</returns>
18 /// <remarks>the function assumes UTC time</remarks> 18 /// <remarks>the function assumes UTC time</remarks>
19 public static DateTime UnixTimestampToDateTime(this uint unixTimestamp) 19 public static DateTime UnixTimestampToDateTime(this uint unixTimestamp)
20 { 20 {
21 return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unixTimestamp).ToUniversalTime(); 21 return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unixTimestamp).ToUniversalTime();
22 } 22 }
23   23  
24 /// <summary> 24 /// <summary>
25 /// Convert a DateTime structure to a Unix timestamp. 25 /// Convert a DateTime structure to a Unix timestamp.
26 /// </summary> 26 /// </summary>
27 /// <param name="dateTime">the DateTime structure to convert</param> 27 /// <param name="dateTime">the DateTime structure to convert</param>
28 /// <returns>the Unix timestamp</returns> 28 /// <returns>the Unix timestamp</returns>
29 /// <remarks>the function assumes UTC time</remarks> 29 /// <remarks>the function assumes UTC time</remarks>
30 public static uint DateTimeToUnixTimestamp(this DateTime dateTime) 30 public static uint DateTimeToUnixTimestamp(this DateTime dateTime)
31 { 31 {
32 return (uint) (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; 32 return (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
33 } 33 }
34 } 34 }
35 } -  
36   35 }
-   36  
37
Generated by GNU Enscript 1.6.5.90.
-  
38   -  
39   -  
40   -