Changeset 499
- Timestamp:
- 01/11/11 04:27:41 (14 years ago)
- Files:
-
- trunk/src/core/time.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/core/time.d
r498 r499 1181 1181 assert(Duration(-120_795).toString() == "-12 ms, -79 ÎŒs, and -5 hnsecs"); 1182 1182 assert(Duration(-12_096_020_900_003).toString() == "-2 weeks, -2 secs, -90 ms, and -3 hnsecs"); 1183 1183 } 1184 1184 1185 1185 1186 1186 /++ 1187 1187 Params: 1188 1188 hnsecs = The total number of hecto-nanoseconds in this duration. 1189 1189 +/ 1190 1190 @safe 1191 this(long hnsecs) pure nothrow1191 pure nothrow this(long hnsecs) 1192 1192 { 1193 1193 _hnsecs = hnsecs; 1194 1194 } 1195 1195 1196 1196 1197 1197 long _hnsecs; 1198 1198 } 1199 1199 1200 1200 1201 1201 /++ … … 1803 1803 throw new TimeException("Attempted division by 0."); 1804 1804 1805 1805 return TickDuration(cast(long)(length / value)); 1806 1806 } 1807 1807 1808 1808 1809 1809 /++ 1810 1810 Params: 1811 1811 ticks = The number of ticks in the TickDuration. 1812 1812 +/ 1813 this(long ticks) pure nothrow1813 pure nothrow this(long ticks) 1814 1814 { 1815 1815 this.length = ticks; 1816 1816 } 1817 1817 1818 1818 1819 1819 /++ 1820 1820 The current system tick. The number of ticks per second varies from 1821 1821 system to system. This uses a monotonic clock, so it's intended for 1822 1822 precision timing by comparing relative time values, not for getting 1823 1823 the current system time. … … 2673 2673 2674 2674 2675 2675 /++ 2676 2676 Params: 2677 2677 hnsecs = The number of hnsecs passed the second. 2678 2678 2679 2679 Throws: 2680 2680 TimeException if the given hnsecs less than 0 or would result in a 2681 2681 FracSec greater than or equal to 1 second. 2682 2682 +/ 2683 this(int hnsecs) pure2683 pure this(int hnsecs) 2684 2684 { 2685 2685 _enforceValid(hnsecs); 2686 2686 _hnsecs = hnsecs; 2687 2687 } 2688 2688 2689 2689 2690 2690 pure invariant() 2691 2691 { 2692 2692 if(!_valid(_hnsecs)) 2693 2693 throw new AssertError("Invaliant Failure: hnsecs [" ~ numToString(_hnsecs) ~ "]", __FILE__, __LINE__); … … 2703 2703 +/ 2704 2704 class TimeException : Exception 2705 2705 { 2706 2706 /++ 2707 2707 Params: 2708 2708 msg = The message for the exception. 2709 2709 file = The file where the exception occurred. 2710 2710 line = The line number where the exception occurred. 2711 2711 next = The previous exception in the chain of exceptions, if any. 2712 2712 +/ 2713 this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) nothrow2713 nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) 2714 2714 { 2715 2715 super(msg, file, line, next); 2716 2716 } 2717 2717 } 2718 2718 2719 2719 2720 2720 //============================================================================== 2721 2721 // Private Section. 2722 2722 // 2723 2723 // Much of this is a copy or simplified copy of what's in std.datetime.
