Time start = Clock.now; Thread.sleep(0.150); Stdout.formatln("slept for {} ms", (Clock.now-start).millis);
long ticks = myTimeSpan.ticks; TimeSpan copyOfMyTimeSpan = TimeSpan(ticks);
const(TimeSpan) t | A TimeSpan value to add |
const(TimeSpan) t | A TimeSpan value to add |
const(TimeSpan) t | A TimeSpan to subtract |
const(TimeSpan) t | A TimeSpan to subtract |
long v | A multiplier to use for scaling this time span. |
long v | A multipler to use for scaling |
long v | A divisor to use for scaling this time span. |
long v | A multipler to use for dividing |
const(TimeSpan) t | A divisor used for dividing |
long value | The number of nanoseconds. |
long value | The number of microseconds. |
long value | The number of milliseconds. |
long value | The number of seconds. |
long value | The number of minutes. |
long value | The number of hours. |
long value | The number of days. |
value | The interval to convert in seconds. |
long ticks = myTime.ticks; Time copyOfMyTime = Time(ticks);
value | A Time value. |
const(TimeSpan) t | A TimeSpan value. |
const(TimeSpan) t | A TimeSpan value. |
const(TimeSpan) t | A TimeSpan value. |
const(Time) t | A Time value. |
const(TimeSpan) t | A TimeSpan value. |
auto unixTime = Clock.now.unix.seconds; auto javaTime = Clock.now.unix.millis;
auto time = Clock.now.time; assert (time.millis < 1000); assert (time.seconds < 60); assert (time.minutes < 60); assert (time.hours < 24);
uint hours | number of hours since midnight |
uint minutes | number of minutes into the hour |
uint seconds | number of seconds into the minute |
uint millis | number of milliseconds into the second |
auto tod = TimeOfDay(100, 100, 100, 10000); assert(tod.hours == 100); assert(tod.minutes == 100); assert(tod.seconds == 100); assert(tod.millis == 10000);
long ticks | ticks representing a Time value. This is normalized so that it represent a time of day (modulo-24 etc) |
assert(TimeSpan.zero > TimeSpan.min); assert(TimeSpan.max > TimeSpan.zero); assert(TimeSpan.max > TimeSpan.min); assert(TimeSpan.zero >= TimeSpan.zero); assert(TimeSpan.zero <= TimeSpan.zero); assert(TimeSpan.max >= TimeSpan.max); assert(TimeSpan.max <= TimeSpan.max); assert(TimeSpan.min >= TimeSpan.min); assert(TimeSpan.min <= TimeSpan.min); assert (TimeSpan.fromSeconds(50).seconds is 50); assert (TimeSpan.fromSeconds(5000).seconds is 5000); assert (TimeSpan.fromMinutes(50).minutes is 50); assert (TimeSpan.fromMinutes(5000).minutes is 5000); assert (TimeSpan.fromHours(23).hours is 23); assert (TimeSpan.fromHours(5000).hours is 5000); assert (TimeSpan.fromDays(6).days is 6); assert (TimeSpan.fromDays(5000).days is 5000); assert (TimeSpan.fromSeconds(50).time.seconds is 50); assert (TimeSpan.fromSeconds(5000).time.seconds is 5000 % 60); assert (TimeSpan.fromMinutes(50).time.minutes is 50); assert (TimeSpan.fromMinutes(5000).time.minutes is 5000 % 60); assert (TimeSpan.fromHours(23).time.hours is 23); assert (TimeSpan.fromHours(5000).time.hours is 5000 % 24); auto ts = TimeSpan.fromHours(20); assert (TimeSpan.fromHours(10) + TimeSpan.fromHours(10) == ts); assert (TimeSpan.fromHours(30) - TimeSpan.fromHours(10) == ts); auto ts2 = TimeSpan.fromHours(10); ts2 += TimeSpan.fromHours(10); assert(ts2 == ts); auto tod = TimeOfDay (25, 2, 3, 4); tod = tod.span.time; assert (tod.hours is 1); assert (tod.minutes is 2); assert (tod.seconds is 3); assert (tod.millis is 4);