std.date
Dates are represented in several formats. The date implementation revolves around a central type, d_time, from which other formats are converted to and from. Dates are calculated using the Gregorian calendar. References:Gregorian calendar (Wikipedia) License:
Boost License 1.0. Authors:
Walter Bright Copyright Digital Mars 2000 - 2009. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at ) http:
//www.boost.org/LICENSE_1_0.txt
- d_time is a signed arithmetic type giving the time elapsed since January 1, 1970. Negative values are for dates preceding 1970. The time unit used is Ticks. Ticks are milliseconds or smaller intervals. The usual arithmetic operations can be performed on d_time, such as adding, subtracting, etc. Elapsed time in Ticks can be computed by subtracting a starting d_time from an ending d_time.
- A value for d_time that does not represent a valid time.
- Time broken down into its components.
- Will be at least 1000
- Compute year and week [1..53] from t. The ISO 8601 week 1 is the first week
of the year that includes January 4. Monday is the first day of the week.
References:
ISO 8601 (Wikipedia) - Calculates the year from the d_time t.
- Determines if d_time t is a leap year.
A leap year is every 4 years except years ending in 00 that are not
divsible by 400.
Returns:
!=0 if it is a leap year. References:
Wikipedia - Calculates the month from the d_time t.
Returns:
Integer in the range 0..11, where 0 represents January and 11 represents December. - Compute which day in a month a d_time t is.
Returns:
Integer in the range 1..31 - Compute which day of the week a d_time t is.
Returns:
Integer in the range 0..6, where 0 represents Sunday and 6 represents Saturday. - Convert from UTC to local time.
- Convert from local time to UTC.
- Determine the date in the month, 1..31, of the nth
weekday.
Parameters:
Returns:int year year int month month, 1..12 int weekday day of week 0..6 representing Sunday..Saturday int n nth occurrence of that weekday in the month, 1..5, where 5 also means "the last occurrence in the month"
the date in the month, 1..31, of the nth weekday - Determine the number of days in a month, 1..31.
Parameters:
int month 1..12 - Converts UTC time into a text string of the form:
"Www Mmm dd hh:mm:ss GMT+-TZ yyyy".
For example, "Tue Apr 02 02:04:57 GMT-0800 1996".
If time is invalid, i.e. is d_time_nan,
the string "Invalid date" is returned.
Example:
d_time lNow; char[] lNowString; // Grab the date and time relative to UTC lNow = std.date.getUTCtime(); // Convert this into the local date and time for display. lNowString = std.date.toString(lNow);
- Converts t into a text string of the form: "Www, dd Mmm yyyy hh:mm:ss UTC". If t is invalid, "Invalid date" is returned.
- Converts the date portion of time into a text string of the form: "Www Mmm dd yyyy", for example, "Tue Apr 02 1996". If time is invalid, "Invalid date" is returned.
- Converts the time portion of t into a text string of the form: "hh:mm:ss GMT+-TZ", for example, "02:04:57 GMT-0800". If t is invalid, "Invalid date" is returned. The input must be in UTC, and the output is in local time.
- Parses s as a textual date string, and returns it as a d_time. If the string is not a valid date, d_time_nan is returned.
- Get current UTC time.
- Type representing the DOS file date/time format.
- Convert from DOS file date/time to d_time.
- Convert from d_time to DOS file date/time.
- Benchmarks code for speed assessment and comparison.
Parameters:
Returns:fun aliases of callable objects (e.g. function names). Each should take no arguments. times The number of times each function is to be executed. result The optional store for the return value. If null is passed in, new store is allocated appropriately.
An array of n uints. Element at slot i contains the number of milliseconds spent in calling the ith function times times. Example:
int a; void f0() { } void f1() { auto b = a; } void f2() { auto b = to!(string)(a); } auto r = benchmark!(f0, f1, f2)(10_000_000);