D Programming Language 2.0

# std.datetime

Module containing Date/Time functionality.

This module provides:

- Types to represent points in time: SysTime, Date, TimeOfDay, and DateTime.
- Types to represent intervals of time.
- Types to represent ranges over intervals of time.
- Types to represent time zones (used by SysTime).
- A platform-independent, high precision stopwatch type: StopWatch
- Benchmarking functions.
- Various helper functions.

Closely related to std.datetime is core.time, and some of the time types used in std.datetime come from there - such as core.time.Duration, core.time.TickDuration, and core.time.FracSec. core.time is publically imported into std.datetime, it isn't necessary to import it separately.

Three of the main concepts used in this module are time points, time durations, and time intervals.

A time point is a specific point in time. e.g. January 5th, 2010 or 5:00.

A time duration is a length of time with units. e.g. 5 days or 231 seconds.

A time interval indicates a period of time associated with a fixed point in time. It is either two time points associated with each other, indicating the time starting at the first point up to, but not including, the second point - e.g. [January 5th, 2010 - March 10th, 2010) - or it is a time point and a time duration associated with one another. e.g. January 5th, 2010 and 5 days, indicating [January 5th, 2010 - January 10th, 2010).

Various arithmetic operations are supported between time points and durations (e.g. the difference between two time points is a time duration), and ranges can be gotten from time intervals, so range-based operations may be done on a series of time points.

The types that the typical user is most likely to be interested in are Date (if they want dates but don't care about time), DateTime (if they want dates and times but don't care about time zones), SysTime (if they want the date and time from the OS and/or do care about time zones), and StopWatch (a platform-independent, high precision stop watch). Date and DateTime are optimized for calendar-based operations, while SysTime is designed for dealing with time from the OS. Check out their specific documentation for more details.

To get the current time, use Clock.currTime. It will return the current time as a SysTime. To print it, toString is sufficient, but if using toISOString, toISOExtString, or toSimpleString, use the corresponding fromISOString, fromISOExtString, or fromISOExtString to create a SysTime from the string.

    auto currentTime = Clock.currTime();
    auto timeString = currentTime.toISOExtString();
    auto restoredTime = SysTime.fromISOExtString(timeString);

Various functions take a string (or strings) to represent a unit of time (e.g. convert!("days", "hours")(numDays)). The valid strings to use with such functions are "years", "months", "weeks", "days", "hours", "minutes", "seconds", "msecs" (milliseconds), "usecs" (microseconds), "hnsecs" (hecto-nanoseconds - i.e. 100 ns), or some subset thereof. There are a few functions in core.time which take "nsecs", but because nothing in std.datetime has precision greater than hnsecs, and very little in core.time does, no functions in std.datetime accept "nsecs". To remember which units are abbreviated and which aren't, all units seconds and greater use their full names, and all sub-second units are abbreviated (since they'd be rather long if they weren't).

Note:
DateTimeException is an alias for core.time's TimeException, so you don't need to worry about core.time functions and std.datetime functions throwing different exception types (except in the rare case that they throw something other than TimeException or DateTimeException).

See Also:
Introduction to std.datetime
ISO 8601
Wikipedia entry on TZ Database
List of Time Zones

License:
Boost License 1.0.

Authors:
Jonathan M Davis and Kato Shoichi

Source:
std/datetime.d

enum Month: ubyte;
  Represents the 12 months of the Gregorian year (January is 1).

  jan

  feb

  mar

  apr

  may

  jun

  jul

  aug

  sep

  oct

  nov

  dec

enum DayOfWeek: ubyte;
  Represents the 7 days of the Gregorian week (Sunday is 0).

  sun

  mon

  tue

  wed

  thu

  fri

  sat

enum AllowDayOverflow: int;
  In some date calculations, adding months or years can cause the date to fall on a day of the month which is not valid (e.g. February 29th 2001 or June 31st 2000). If overflow is allowed (as is the default), then the month will be incremented accordingly (so, February 29th 2001 would become March 1st 2001, and June 31st 2000 would become July 1st 2000). If overflow is not allowed, then the day will be adjusted to the last valid day in that month (so, February 29th 2001 would become February 28th 2001 and June 31st 2000 would become June 30th 2000).

  AllowDayOverflow only applies to calculations involving months or years.

  no
    No, don't allow day overflow.

  yes
    Yes, allow day overflow.

enum Direction: int;
  Indicates a direction in time. One example of its use is Interval's expand function which uses it to indicate whether the interval should be expanded backwards (into the past), forwards (into the future), or both.

  bwd
    Backward.

  fwd
    Forward.

  both
    Both backward and forward.

enum PopFirst: int;
  Used to indicate whether popFront should be called immediately upon creating a range. The idea is that for some functions used to generate a range for an interval, front is not necessarily a time point which would ever be generated by the range. To get the first time point in the range to match what the function generates, then use PopFirst.yes to indicate that the range should have popFront called on it before the range is returned so that front is a time point which the function would generate.

  For instance, if the function used to generate a range of time points generated successive Easters (i.e. you're iterating over all of the Easters within the interval), the initial date probably isn't an Easter. Using PopFirst.yes would tell the function which returned the range that popFront was to be called so that front would then be an Easter - the next one generated by the function (which when iterating forward would be the Easter following the original front, while when iterating backward, it would be the Easter prior to the original front). If PopFirst.no were used, then front would remain the original time point and it would not necessarily be a time point which would be generated by the range-generating function (which in many cases is exactly what is desired - e.g. if iterating over every day starting at the beginning of the interval).

  no
    No, don't call popFront() before returning the range.

  yes
    Yes, call popFront() before returning the range.

enum AutoStart: int;
  Used by StopWatch to indicate whether it should start immediately upon construction.

  no
    No, don't start the StopWatch when it is constructed.

  yes
    Yes, do start the StopWatch when it is constructed.

immutable string[] timeStrings;
  Array of the strings representing time units, starting with the smallest unit and going to the largest. It does not include "nsecs".

  Includes "hnsecs" (hecto-nanoseconds (100 ns)), "usecs" (microseconds), "msecs" (milliseconds), "seconds", "minutes", "hours", "days", "weeks", "months", and "years"

alias DateTimeException = core.time.TimeException;
  Exception type used by std.datetime. It's an alias to TimeException, which is what core.time uses. Either can be caught without concern about which module it came from.

class Clock;
  Effectively a namespace to make it clear that the methods it contains are getting the time from the system clock. It cannot be instantiated.

  static SysTime currTime(immutable TimeZone tz = LocalTime());
    Returns the current time in the given time zone.

    Throws:
    ErrnoException (on Posix) or Exception (on Windows) if it fails to get the time of day.

  static @property @trusted long currStdTime();
    Returns the number of hnsecs since midnight, January 1st, 1 A.D. for the current time.

    Throws:
    DateTimeException if it fails to get the time.

  static @property @safe TickDuration currSystemTick();
    The current system tick. The number of ticks per second varies from system to system. currSystemTick uses a monotonic clock, so it's intended for precision timing by comparing relative time values, not for getting the current system time.

    Warning:
    On some systems, the monotonic clock may stop counting when the computer goes to sleep or hibernates. So, the monotonic clock could be off if that occurs. This is known to happen on Mac OS X. It has not been tested whether it occurs on either Windows or Linux.

    Throws:
    DateTimeException if it fails to get the time.

  static @property @safe TickDuration currAppTick();
    The current number of system ticks since the application started. The number of ticks per second varies from system to system. This uses a monotonic clock.

    Warning:
    On some systems, the monotonic clock may stop counting when the computer goes to sleep or hibernates. So, the monotonic clock could be off if that occurs. This is known to happen on Mac OS X. It has not been tested whether it occurs on either Windows or on Linux.

    Throws:
    DateTimeException if it fails to get the time.

struct SysTime;
  SysTime is the type used to get the current time from the system or doing anything that involves time zones. Unlike DateTime, the time zone is an integral part of SysTime (though for local time applications, time zones can be ignored and it will work, since it defaults to using the local time zone). It holds its internal time in std time (hnsecs since midnight, January 1st, 1 A.D. UTC), so it interfaces well with the system time. However, that means that, unlike DateTime, it is not optimized for calendar-based operations, and getting individual units from it such as years or days is going to involve conversions and be less efficient.

  For calendar-based operations that don't care about time zones, then DateTime would be the type to use. For system time, use SysTime.

  Clock.currTime will return the current time as a SysTime. To convert a SysTime to a Date or DateTime, simply cast it. To convert a Date or DateTime to a SysTime, use SysTime's constructor, and pass in the intended time zone with it (or don't pass in a TimeZone, and the local time zone will be used). Be aware, however, that converting from a DateTime to a SysTime will not necessarily be 100% accurate due to DST (one hour of the year doesn't exist and another occurs twice). To not risk any conversion errors, keep times as SysTimes. Aside from DST though, there shouldn't be any conversion problems.

  For using time zones other than local time or UTC, use PosixTimeZone on Posix systems (or on Windows, if providing the TZ Database files), and use WindowsTimeZone on Windows systems. The time in SysTime is kept internally in hnsecs from midnight, January 1st, 1 A.D. UTC. Conversion error cannot happen when changing the time zone of a SysTime. LocalTime is the TimeZone class which represents the local time, and UTC is the TimeZone class which represents UTC. SysTime uses LocalTime if no TimeZone is provided. For more details on time zones, see the documentation for TimeZone, PosixTimeZone, and WindowsTimeZone.

  SysTime's range is from approximately 29,000 B.C. to approximately 29,000 A.D.

  nothrow this(in DateTime dateTime, immutable TimeZone tz = null);
    Parameters:

    DateTime dateTime | The DateTime to use to set this SysTime's internal std time. As DateTime has no concept of time zone, tz is used as its time zone.
    TimeZone tz | The TimeZone to use for this SysTime. If null, LocalTime will be used. The given DateTime is assumed to be in the given time zone.

  this(in DateTime dateTime, in FracSec fracSec, immutable TimeZone tz = null);
    Parameters:

    DateTime dateTime | The DateTime to use to set this SysTime's internal std time. As DateTime has no concept of time zone, tz is used as its time zone.
    FracSec fracSec | The fractional seconds portion of the time.
    TimeZone tz | The TimeZone to use for this SysTime. If null, LocalTime will be used. The given DateTime is assumed to be in the given time zone.

    Throws:
    DateTimeException if fracSec is negative.

  nothrow this(in Date date, immutable TimeZone tz = null);
    Parameters:

    Date date | The Date to use to set this SysTime's internal std time. As Date has no concept of time zone, tz is used as its time zone.
    TimeZone tz | The TimeZone to use for this SysTime. If null, LocalTime will be used. The given Date is assumed to be in the given time zone.

  pure nothrow this(long stdTime, immutable TimeZone tz = null);
    Note:
    Whereas the other constructors take in the given date/time, assume that it's in the given time zone, and convert it to hnsecs in UTC since midnight, January 1st, 1 A.D. UTC - i.e. std time - this constructor takes a std time, which is specifically already in UTC, so no conversion takes place. Of course, the various getter properties and functions will use the given time zone's conversion function to convert the results to that time zone, but no conversion of the arguments to this constructor takes place.

    Parameters:

    long stdTime | The number of hnsecs since midnight, January 1st, 1 A.D. UTC.
    TimeZone tz | The TimeZone to use for this SysTime. If null, LocalTime will be used.

  pure nothrow ref SysTime opAssign(ref const SysTime rhs);
    Parameters:

    SysTime rhs | The SysTime to assign to this one.

  pure nothrow ref SysTime opAssign(SysTime rhs);
    Parameters:

    SysTime rhs | The SysTime to assign to this one.

  const pure nothrow bool opEquals(const SysTime rhs);
  const pure nothrow bool opEquals(ref const SysTime rhs);
    Checks for equality between this SysTime and the given SysTime.

    Note that the time zone is ignored. Only the internal std times (which are in UTC) are compared.

  const pure nothrow int opCmp(in SysTime rhs);
    Compares this SysTime with the given SysTime.

    Time zone is irrelevant when comparing SysTimes.

    Returns:

    this < rhs | < 0
    this == rhs | 0
    this > rhs | > 0

  const nothrow @property short year();
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

  @property void year(int year);
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

    Parameters:

    int year | The year to set this SysTime's year to.

    Throws:
    DateTimeException if the new year is not a leap year and the resulting date would be on February 29th.

    Examples:

        assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).year == 1999);
        assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).year == 2010);
        assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).year == -7);

  const @property ushort yearBC();
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Throws:
    DateTimeException if isAD is true.

    Examples:

        assert(SysTime(DateTime(0, 1, 1, 12, 30, 33)).yearBC == 1);
        assert(SysTime(DateTime(-1, 1, 1, 10, 7, 2)).yearBC == 2);
        assert(SysTime(DateTime(-100, 1, 1, 4, 59, 0)).yearBC == 101);

  @property void yearBC(int year);
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Parameters:

    int year | The year B.C. to set this SysTime's year to.

    Throws:
    DateTimeException if a non-positive value is given.

    Examples:

        auto st = SysTime(DateTime(2010, 1, 1, 7, 30, 0));
        st.yearBC = 1;
        assert(st == SysTime(DateTime(0, 1, 1, 7, 30, 0)));

        st.yearBC = 10;
        assert(st == SysTime(DateTime(-9, 1, 1, 7, 30, 0)));

  const nothrow @property Month month();
    Month of a Gregorian Year.

    Examples:

        assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).month == 7);
        assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).month == 10);
        assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).month == 4);

  @property void month(Month month);
    Month of a Gregorian Year.

    Parameters:

    Month month | The month to set this SysTime's month to.

    Throws:
    DateTimeException if the given month is not a valid month.

  const nothrow @property ubyte day();
    Day of a Gregorian Month.

    Examples:

        assert(SysTime(DateTime(1999, 7, 6, 9, 7, 5)).day == 6);
        assert(SysTime(DateTime(2010, 10, 4, 0, 0, 30)).day == 4);
        assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).day == 5);

  @property void day(int day);
    Day of a Gregorian Month.

    Parameters:

    int day | The day of the month to set this SysTime's day to.

    Throws:
    DateTimeException if the given day is not a valid day of the current month.

  const nothrow @property ubyte hour();
    Hours past midnight.

  @property void hour(int hour);
    Hours past midnight.

    Parameters:

    int hour | The hours to set this SysTime's hour to.

    Throws:
    DateTimeException if the given hour are not a valid hour of the day.

  const nothrow @property ubyte minute();
    Minutes past the current hour.

  @property void minute(int minute);
    Minutes past the current hour.

    Parameters:

    minutes | The minute to set this SysTime's minute to.

    Throws:
    DateTimeException if the given minute are not a valid minute of an hour.

  const nothrow @property ubyte second();
    Seconds past the current minute.

  @property void second(int second);
    Seconds past the current minute.

    Parameters:

    int second | The second to set this SysTime's second to.

    Throws:
    DateTimeException if the given second are not a valid second of a minute.

  const nothrow @property FracSec fracSec();
    Fractional seconds passed the second.

  @property void fracSec(FracSec fracSec);
    Fractional seconds passed the second.

    Parameters:

    FracSec fracSec | The fractional seconds to set this SysTimes's fractional seconds to.

    Throws:
    DateTimeException if fracSec is negative.

  const pure nothrow @property long stdTime();
    The total hnsecs from midnight, January 1st, 1 A.D. UTC. This is the internal representation of SysTime.

  pure nothrow @property void stdTime(long stdTime);
    The total hnsecs from midnight, January 1st, 1 A.D. UTC. This is the internal representation of SysTime.

    Parameters:

    long stdTime | The number of hnsecs since January 1st, 1 A.D. UTC.

  const pure nothrow @property immutable(TimeZone) timezone();
    The current time zone of this SysTime. Its internal time is always kept in UTC, so there are no conversion issues between time zones due to DST. Functions which return all or part of the time - such as hours - adjust the time to this SysTime's time zone before returning.

  pure nothrow @property void timezone(immutable TimeZone timezone);
    The current time zone of this SysTime. It's internal time is always kept in UTC, so there are no conversion issues between time zones due to DST. Functions which return all or part of the time - such as hours - adjust the time to this SysTime's time zone before returning.

    Parameters:

    tz | The TimeZone to set this SysTime's time zone to.

  const nothrow @property bool dstInEffect();
    Returns whether DST is in effect for this SysTime.

  const nothrow @property Duration utcOffset();
    Returns what the offset from UTC is for this SysTime. It includes the DST offset in effect at that time (if any).

  const nothrow SysTime toLocalTime();
    Returns a SysTime with the same std time as this one, but with LocalTime as its time zone.

  const pure nothrow SysTime toUTC();
    Returns a SysTime with the same std time as this one, but with UTC as its time zone.

  const pure nothrow SysTime toOtherTZ(immutable TimeZone tz);
    Returns a SysTime with the same std time as this one, but with given time zone as its time zone.

  const pure nothrow time_t toUnixTime();
    Returns a time_t which represents the same time as this SysTime.

    Note that like all conversions in std.datetime, this is a truncating conversion.

    If time_t is 32 bits, rather than 64, and the result can't fit in a 32-bit value, then the closest value that can be held in 32 bits will be used (so time_t.max if it goes over and time_t.min if it goes under).

  const pure nothrow timeval toTimeVal();
    Returns a timeval which represents this SysTime.

    Note that like all conversions in std.datetime, this is a truncating conversion.

    If time_t is 32 bits, rather than 64, and the result can't fit in a 32-bit value, then the closest value that can be held in 32 bits will be used for tv_sec. (so time_t.max if it goes over and time_t.min if it goes under).

  const nothrow tm toTM();
    Returns a tm which represents this SysTime.

  nothrow SysTime add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years" || units == "months");
    Adds the given number of years or months to this SysTime. A negative number will subtract.

    Note that if day overflow is allowed, and the date with the adjusted year/month overflows the number of days in the new month, then the month will be incremented by one, and the day set to the number of days overflowed. (e.g. if the day were 31 and the new month were June, then the month would be incremented to July, and the new day would be 1). If day overflow is not allowed, then the day will be set to the last valid day in the month (e.g. June 31st would become June 30th).

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this SysTime.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow, causing the month to increment.

    Examples:

        auto st1 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
        st1.add!"months"(11);
        assert(st1 == SysTime(DateTime(2010, 12, 1, 12, 30, 33)));

        auto st2 = SysTime(DateTime(2010, 1, 1, 12, 30, 33));
        st2.add!"months"(-11);
        assert(st2 == SysTime(DateTime(2009, 2, 1, 12, 30, 33)));

        auto st3 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
        st3.add!"years"(1);
        assert(st3 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));

        auto st4 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
        st4.add!"years"(1, AllowDayOverflow.no);
        assert(st4 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));

  nothrow void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years");
    Adds the given number of years or months to this SysTime. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. Rolling a SysTime 12 months gets the exact same SysTime. However, the days can still be affected due to the differing number of days in each month.

    Because there are no units larger than years, there is no difference between adding and rolling years.

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this SysTime.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow, causing the month to increment.

    Examples:

        auto st1 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
        st1.roll!"months"(1);
        assert(st1 == SysTime(DateTime(2010, 2, 1, 12, 33, 33)));

        auto st2 = SysTime(DateTime(2010, 1, 1, 12, 33, 33));
        st2.roll!"months"(-1);
        assert(st2 == SysTime(DateTime(2010, 12, 1, 12, 33, 33)));

        auto st3 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
        st3.roll!"months"(1);
        assert(st3 == SysTime(DateTime(1999, 3, 1, 12, 33, 33)));

        auto st4 = SysTime(DateTime(1999, 1, 29, 12, 33, 33));
        st4.roll!"months"(1, AllowDayOverflow.no);
        assert(st4 == SysTime(DateTime(1999, 2, 28, 12, 33, 33)));

        auto st5 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
        st5.roll!"years"(1);
        assert(st5 == SysTime(DateTime(2001, 3, 1, 12, 30, 33)));

        auto st6 = SysTime(DateTime(2000, 2, 29, 12, 30, 33));
        st6.roll!"years"(1, AllowDayOverflow.no);
        assert(st6 == SysTime(DateTime(2001, 2, 28, 12, 30, 33)));

  nothrow void roll(string units)(long value) if (units == "days");
    Adds the given number of units to this SysTime. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. For instance, rolling a SysTime one year's worth of days gets the exact same SysTime.

    Accepted units are "days", "minutes", "hours", "minutes", "seconds", "msecs", "usecs", and "hnsecs".

    Note that when rolling msecs, usecs or hnsecs, they all add up to a second. So, for example, rolling 1000 msecs is exactly the same as rolling 100,000 usecs.

    Parameters:

    units | The units to add.
    long value | The number of units to add to this SysTime.

    Examples:

        auto st1 = SysTime(DateTime(2010, 1, 1, 11, 23, 12));
        st1.roll!"days"(1);
        assert(st1 == SysTime(DateTime(2010, 1, 2, 11, 23, 12)));
        st1.roll!"days"(365);
        assert(st1 == SysTime(DateTime(2010, 1, 26, 11, 23, 12)));
        st1.roll!"days"(-32);
        assert(st1 == SysTime(DateTime(2010, 1, 25, 11, 23, 12)));

        auto st2 = SysTime(DateTime(2010, 7, 4, 12, 0, 0));
        st2.roll!"hours"(1);
        assert(st2 == SysTime(DateTime(2010, 7, 4, 13, 0, 0)));

        auto st3 = SysTime(DateTime(2010, 1, 1, 0, 0, 0));
        st3.roll!"seconds"(-1);
        assert(st3 == SysTime(DateTime(2010, 1, 1, 0, 0, 59)));

        auto st4 = SysTime(DateTime(2010, 1, 1, 0, 0, 0),
                           FracSec.from!"usecs"(2_400));
        st4.roll!"usecs"(-1_200_000);
        assert(st4 == SysTime(DateTime(2010, 1, 1, 0, 0, 0),
                              FracSec.from!"usecs"(802_400)));

  const pure nothrow SysTime opBinary(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this SysTime.

    The legal types of arithmetic for SysTime using this operator are

    SysTime | + | duration | --> | SysTime
    SysTime | - | duration | --> | SysTime

    Parameters:

    D duration | The duration to add to or subtract from this SysTime.

  pure nothrow SysTime opOpAssign(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this SysTime, as well as assigning the result to this SysTime.

    The legal types of arithmetic for SysTime using this operator are

    SysTime | + | duration | --> | SysTime
    SysTime | - | duration | --> | SysTime

    Parameters:

    D duration | The duration to add to or subtract from this SysTime.

  const pure nothrow Duration opBinary(string op)(in SysTime rhs) if (op == "-");
    Gives the difference between two SysTimes.

    The legal types of arithmetic for SysTime using this operator are

    SysTime | - | SysTime | --> | duration

  const nothrow int diffMonths(in SysTime rhs);
    Returns the difference between the two SysTimes in months.

    To get the difference in years, subtract the year property of two SysTimes. To get the difference in days or weeks, subtract the SysTimes themselves and use the Duration that results. Because converting between months and smaller units requires a specific date (which Durations don't have), getting the difference in months requires some math using both the year and month properties, so this is a convenience function for getting the difference in months.

    Note that the number of days in the months or how far into the month either date is is irrelevant. It is the difference in the month property combined with the difference in years * 12. So, for instance, December 31st and January 1st are one month apart just as December 1st and January 31st are one month apart.

    Parameters:

    SysTime rhs | The SysTime to subtract from this one.

    Examples:

        assert(SysTime(Date(1999, 2, 1)).diffMonths(SysTime(Date(1999, 1, 31))) == 1);
        assert(SysTime(Date(1999, 1, 31)).diffMonths(SysTime(Date(1999, 2, 1))) == -1);
        assert(SysTime(Date(1999, 3, 1)).diffMonths(SysTime(Date(1999, 1, 1))) == 2);
        assert(SysTime(Date(1999, 1, 1)).diffMonths(SysTime(Date(1999, 3, 31))) == -2);

  const nothrow @property bool isLeapYear();
    Whether this SysTime is in a leap year.

  const nothrow @property DayOfWeek dayOfWeek();
    Day of the week this SysTime is on.

  const nothrow @property ushort dayOfYear();
    Day of the year this SysTime is on.

    Examples:

        assert(SysTime(DateTime(1999, 1, 1, 12, 22, 7)).dayOfYear == 1);
        assert(SysTime(DateTime(1999, 12, 31, 7, 2, 59)).dayOfYear == 365);
        assert(SysTime(DateTime(2000, 12, 31, 21, 20, 0)).dayOfYear == 366);

  @property void dayOfYear(int day);
    Day of the year.

    Parameters:

    int day | The day of the year to set which day of the year this SysTime is on.

  const nothrow @property int dayOfGregorianCal();
    The Xth day of the Gregorian Calendar that this SysTime is on.

    Examples:

        assert(SysTime(DateTime(1, 1, 1, 0, 0, 0)).dayOfGregorianCal == 1);
        assert(SysTime(DateTime(1, 12, 31, 23, 59, 59)).dayOfGregorianCal == 365);
        assert(SysTime(DateTime(2, 1, 1, 2, 2, 2)).dayOfGregorianCal == 366);

        assert(SysTime(DateTime(0, 12, 31, 7, 7, 7)).dayOfGregorianCal == 0);
        assert(SysTime(DateTime(0, 1, 1, 19, 30, 0)).dayOfGregorianCal == -365);
        assert(SysTime(DateTime(-1, 12, 31, 4, 7, 0)).dayOfGregorianCal == -366);

        assert(SysTime(DateTime(2000, 1, 1, 9, 30, 20)).dayOfGregorianCal == 730_120);
        assert(SysTime(DateTime(2010, 12, 31, 15, 45, 50)).dayOfGregorianCal == 734_137);

  nothrow @property void dayOfGregorianCal(int days);
    The Xth day of the Gregorian Calendar that this SysTime is on. Setting this property does not affect the time portion of SysTime.

    Parameters:

    int days | The day of the Gregorian Calendar to set this SysTime to.

    Examples:

        auto st = SysTime(DateTime(0, 0, 0, 12, 0, 0));
        st.dayOfGregorianCal = 1;
        assert(st == SysTime(DateTime(1, 1, 1, 12, 0, 0)));

        st.dayOfGregorianCal = 365;
        assert(st == SysTime(DateTime(1, 12, 31, 12, 0, 0)));

        st.dayOfGregorianCal = 366;
        assert(st == SysTime(DateTime(2, 1, 1, 12, 0, 0)));

        st.dayOfGregorianCal = 0;
        assert(st == SysTime(DateTime(0, 12, 31, 12, 0, 0)));

        st.dayOfGregorianCal = -365;
        assert(st == SysTime(DateTime(-0, 1, 1, 12, 0, 0)));

        st.dayOfGregorianCal = -366;
        assert(st == SysTime(DateTime(-1, 12, 31, 12, 0, 0)));

        st.dayOfGregorianCal = 730_120;
        assert(st == SysTime(DateTime(2000, 1, 1, 12, 0, 0)));

        st.dayOfGregorianCal = 734_137;
        assert(st == SysTime(DateTime(2010, 12, 31, 12, 0, 0)));

  const nothrow @property ubyte isoWeek();
    The ISO 8601 week of the year that this SysTime is in.

    See Also:
    ISO Week Date.

  const nothrow @property SysTime endOfMonth();
    SysTime for the last day in the month that this Date is in. The time portion of endOfMonth is always 23:59:59.9999999.

    Examples:

        assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).endOfMonth ==
               SysTime(DateTime(1999, 1, 31, 23, 59, 59),
                       FracSec.from!"hnsecs"(9_999_999)));

        assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0),
                       FracSec.from!"msecs"(24)).endOfMonth ==
               SysTime(DateTime(1999, 2, 28, 23, 59, 59),
                       FracSec.from!"hnsecs"(9_999_999)));

        assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27),
                       FracSec.from!"usecs"(5203)).endOfMonth ==
               SysTime(DateTime(2000, 2, 29, 23, 59, 59),
                       FracSec.from!"hnsecs"(9_999_999)));

        assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9),
                       FracSec.from!"hnsecs"(12345)).endOfMonth ==
               SysTime(DateTime(2000, 6, 30, 23, 59, 59),
                       FracSec.from!"hnsecs"(9_999_999)));

  const nothrow @property ubyte daysInMonth();
    The last day in the month that this SysTime is in.

    Examples:

        assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).daysInMonth == 31);
        assert(SysTime(DateTime(1999, 2, 7, 19, 30, 0)).daysInMonth == 28);
        assert(SysTime(DateTime(2000, 2, 7, 5, 12, 27)).daysInMonth == 29);
        assert(SysTime(DateTime(2000, 6, 4, 12, 22, 9)).daysInMonth == 30);

  const nothrow @property bool isAD();
    Whether the current year is a date in A.D.

    Examples:

        assert(SysTime(DateTime(1, 1, 1, 12, 7, 0)).isAD);
        assert(SysTime(DateTime(2010, 12, 31, 0, 0, 0)).isAD);
        assert(!SysTime(DateTime(0, 12, 31, 23, 59, 59)).isAD);
        assert(!SysTime(DateTime(-2010, 1, 1, 2, 2, 2)).isAD);

  const nothrow @property long julianDay();
    The julian day for this SysTime at the given time. For example, prior to noon, 1996-03-31 would be the julian day number 2450_173, so this function returns 2450_173, while from noon onward, the julian day number would be 2450_174, so this function returns 2450_174.

  const nothrow @property long modJulianDay();
    The modified julian day for any time on this date (since, the modified julian day changes at midnight).

  const nothrow Date opCast(T)() if (is(Unqual!T == Date));
    Returns a Date equivalent to this SysTime.

  const nothrow DateTime opCast(T)() if (is(Unqual!T == DateTime));
    Returns a DateTime equivalent to this SysTime.

  const nothrow TimeOfDay opCast(T)() if (is(Unqual!T == TimeOfDay));
    Returns a TimeOfDay equivalent to this SysTime.

  const nothrow string toISOString();
    Converts this SysTime to a string with the format YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds and TZ is time zone).

    Note that the number of digits in the fractional seconds varies with the number of fractional seconds. It's a maximum of 7 (which would be hnsecs), but only has as many as are necessary to hold the correct value (so no trailing zeroes), and if there are no fractional seconds, then there is no decimal point.

    If this SysTime's time zone is LocalTime, then TZ is empty. If its time zone is UTC, then it is "Z". Otherwise, it is the offset from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC is not enough to uniquely identify the time zone.

    Time zone offsets will be in the form +HH:MM or -HH:MM.

    Examples:

        assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOString() ==
               "20100704T070612");

        assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
                       FracSec.from!"msecs"(24)).toISOString() ==
               "19981225T021500.024");

        assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOString() ==
               "00000105T230959");

        assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
                       FracSec.from!"hnsecs"(520_920)).toISOString() ==
               "-00040105T000002.052092");

  const nothrow string toISOExtString();
    Converts this SysTime to a string with the format YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ is the time zone).

    Note that the number of digits in the fractional seconds varies with the number of fractional seconds. It's a maximum of 7 (which would be hnsecs), but only has as many as are necessary to hold the correct value (so no trailing zeroes), and if there are no fractional seconds, then there is no decimal point.

    If this SysTime's time zone is LocalTime, then TZ is empty. If its time zone is UTC, then it is "Z". Otherwise, it is the offset from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC is not enough to uniquely identify the time zone.

    Time zone offsets will be in the form +HH:MM or -HH:MM.

    Examples:

        assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() ==
               "2010-07-04T07:06:12");

        assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
                       FracSec.from!"msecs"(24)).toISOExtString() ==
               "1998-12-25T02:15:00.024");

        assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOExtString() ==
               "0000-01-05T23:09:59");

        assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
                       FracSec.from!"hnsecs"(520_920)).toISOExtString() ==
               "-0004-01-05T00:00:02.052092");

  const nothrow string toSimpleString();
    Converts this SysTime to a string with the format YYYY-Mon-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ is the time zone).

    Note that the number of digits in the fractional seconds varies with the number of fractional seconds. It's a maximum of 7 (which would be hnsecs), but only has as many as are necessary to hold the correct value (so no trailing zeroes), and if there are no fractional seconds, then there is no decimal point.

    If this SysTime's time zone is LocalTime, then TZ is empty. If its time zone is UTC, then it is "Z". Otherwise, it is the offset from UTC (e.g. +1:00 or -7:00). Note that the offset from UTC is not enough to uniquely identify the time zone.

    Time zone offsets will be in the form +HH:MM or -HH:MM.

    Examples:

        assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toSimpleString() ==
               "2010-Jul-04 07:06:12");

        assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0),
                       FracSec.from!"msecs"(24)).toSimpleString() ==
               "1998-Dec-25 02:15:00.024");

        assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toSimpleString() ==
               "0000-Jan-05 23:09:59");

        assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2),
                       FracSec.from!"hnsecs"(520_920)).toSimpleString() ==
                "-0004-Jan-05 00:00:02.052092");

  const nothrow string toString();
    Converts this SysTime to a string.

  SysTime fromISOString(S)(in S isoString, immutable TimeZone tz = null) if (isSomeString!S);
    Creates a SysTime from a string with the format YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds is the time zone). Whitespace is stripped from the given string.

    The exact format is exactly as described in toISOString except that trailing zeroes are permitted - including having fractional seconds with all zeroes. However, a decimal point with nothing following it is invalid.

    If there is no time zone in the string, then LocalTime is used. If the time zone is "Z", then UTC is used. Otherwise, a SimpleTimeZone which corresponds to the given offset from UTC is used. To get the returned SysTime to be a particular time zone, pass in that time zone and the SysTime to be returned will be converted to that time zone (though it will still be read in as whatever time zone is in its string).

    The accepted formats for time zone offsets are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.

    Parameters:

    S isoString | A string formatted in the ISO format for dates and times.
    TimeZone tz | The time zone to convert the given time to (no conversion occurs if null).

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting SysTime would not be valid.

    Examples:

        assert(SysTime.fromISOString("20100704T070612") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
        assert(SysTime.fromISOString("19981225T021500.007") ==
               SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
        assert(SysTime.fromISOString("00000105T230959.00002") ==
               SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
        assert(SysTime.fromISOString("-00040105T000002") ==
               SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
        assert(SysTime.fromISOString(" 20100704T070612 ") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));

        assert(SysTime.fromISOString("20100704T070612Z") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
        assert(SysTime.fromISOString("20100704T070612-8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(-8))));
        assert(SysTime.fromISOString("20100704T070612+8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(8))));

  SysTime fromISOExtString(S)(in S isoExtString, immutable TimeZone tz = null) if (isSomeString!S);
    Creates a SysTime from a string with the format YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the time zone). Whitespace is stripped from the given string.

    The exact format is exactly as described in toISOExtString except that trailing zeroes are permitted - including having fractional seconds with all zeroes. However, a decimal point with nothing following it is invalid.

    If there is no time zone in the string, then LocalTime is used. If the time zone is "Z", then UTC is used. Otherwise, a SimpleTimeZone which corresponds to the given offset from UTC is used. To get the returned SysTime to be a particular time zone, pass in that time zone and the SysTime to be returned will be converted to that time zone (though it will still be read in as whatever time zone is in its string).

    The accepted formats for time zone offsets are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.

    Parameters:

    isoString | A string formatted in the ISO Extended format for dates and times.
    TimeZone tz | The time zone to convert the given time to (no conversion occurs if null).

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting SysTime would not be valid.

    Examples:

        assert(SysTime.fromISOExtString("2010-07-04T07:06:12") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
        assert(SysTime.fromISOExtString("1998-12-25T02:15:00.007") ==
               SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
        assert(SysTime.fromISOExtString("0000-01-05T23:09:59.00002") ==
               SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
        assert(SysTime.fromISOExtString("-0004-01-05T00:00:02") ==
               SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
        assert(SysTime.fromISOExtString(" 2010-07-04T07:06:12 ") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));

        assert(SysTime.fromISOExtString("2010-07-04T07:06:12Z") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
        assert(SysTime.fromISOExtString("2010-07-04T07:06:12-8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(-8))));
        assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(8))));

  SysTime fromSimpleString(S)(in S simpleString, immutable TimeZone tz = null) if (isSomeString!S);
    Creates a SysTime from a string with the format YYYY-MM-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the time zone). Whitespace is stripped from the given string.

    The exact format is exactly as described in toSimpleString except that trailing zeroes are permitted - including having fractional seconds with all zeroes. However, a decimal point with nothing following it is invalid.

    If there is no time zone in the string, then LocalTime is used. If the time zone is "Z", then UTC is used. Otherwise, a SimpleTimeZone which corresponds to the given offset from UTC is used. To get the returned SysTime to be a particular time zone, pass in that time zone and the SysTime to be returned will be converted to that time zone (though it will still be read in as whatever time zone is in its string).

    The accepted formats for time zone offsets are +H, -H, +HH, -HH, +H:MM, -H:MM, +HH:MM, and -HH:MM.

    Parameters:

    S simpleString | A string formatted in the way that toSimpleString formats dates and times.
    TimeZone tz | The time zone to convert the given time to (no conversion occurs if null).

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting SysTime would not be valid.

    Examples:

        assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));
        assert(SysTime.fromSimpleString("1998-Dec-25 02:15:00.007") ==
               SysTime(DateTime(1998, 12, 25, 2, 15, 0), FracSec.from!"msecs"(7)));
        assert(SysTime.fromSimpleString("0000-Jan-05 23:09:59.00002") ==
               SysTime(DateTime(0, 1, 5, 23, 9, 59), FracSec.from!"usecs"(20)));
        assert(SysTime.fromSimpleString("-0004-Jan-05 00:00:02") ==
               SysTime(DateTime(-4, 1, 5, 0, 0, 2)));
        assert(SysTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12)));

        assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12Z") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12), UTC()));
        assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12-8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(-8))));
        assert(SysTime.fromSimpleString("2010-Jul-04 07:06:12+8:00") ==
               SysTime(DateTime(2010, 7, 4, 7, 6, 12),
                       new SimpleTimeZone(dur!"hours"(8))));

  static pure nothrow @property SysTime min();
    Returns the SysTime farthest in the past which is representable by SysTime.

    The SysTime which is returned is in UTC.

  static pure nothrow @property SysTime max();
    Returns the SysTime farthest in the future which is representable by SysTime.

    The SysTime which is returned is in UTC.

struct Date;
  Represents a date in the Proleptic Gregorian Calendar ranging from 32,768 B.C. to 32,767 A.D. Positive years are A.D. Non-positive years are B.C.

  Year, month, and day are kept separately internally so that Date is optimized for calendar-based operations.

  Date uses the Proleptic Gregorian Calendar, so it assumes the Gregorian leap year calculations for its entire length. And, as per ISO 8601, it also treats 1 B.C. as year 0. So, 1 B.C. is 0, 2 B.C. is -1, etc. Use yearBC if want B.C. as a positive integer with 1 B.C. being the year prior to 1 A.D.

  Year 0 is a leap year.

  pure this(int year, int month, int day);
    Throws:
    DateTimeException if the resulting Date would not be valid.

    Parameters:

    int year | Year of the Gregorian Calendar. Positive values are A.D. Non-positive values are B.C. with year 0 being the year prior to 1 A.D.
    int month | Month of the year.
    int day | Day of the month.

  pure nothrow this(int day);
    Parameters:

    int day | The Xth day of the Gregorian Calendar that the constructed Date will be for.

  const pure nothrow int opCmp(in Date rhs);
    Compares this Date with the given Date.

    Returns:

    this < rhs | < 0
    this == rhs | 0
    this > rhs | > 0

  const pure nothrow @property short year();
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

    Examples:

        assert(Date(1999, 7, 6).year == 1999);
        assert(Date(2010, 10, 4).year == 2010);
        assert(Date(-7, 4, 5).year == -7);

  pure @property void year(int year);
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

    Parameters:

    int year | The year to set this Date's year to.

    Throws:
    DateTimeException if the new year is not a leap year and the resulting date would be on February 29th.

  const pure @property ushort yearBC();
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Throws:
    DateTimeException if isAD is true.

    Examples:

        assert(Date(0, 1, 1).yearBC == 1);
        assert(Date(-1, 1, 1).yearBC == 2);
        assert(Date(-100, 1, 1).yearBC == 101);

  pure @property void yearBC(int year);
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Parameters:

    int year | The year B.C. to set this Date's year to.

    Throws:
    DateTimeException if a non-positive value is given.

    Examples:

        auto date = Date(2010, 1, 1);
        date.yearBC = 1;
        assert(date == Date(0, 1, 1));

        date.yearBC = 10;
        assert(date == Date(-9, 1, 1));

  const pure nothrow @property Month month();
    Month of a Gregorian Year.

    Examples:

        assert(Date(1999, 7, 6).month == 7);
        assert(Date(2010, 10, 4).month == 10);
        assert(Date(-7, 4, 5).month == 4);

  pure @property void month(Month month);
    Month of a Gregorian Year.

    Parameters:

    Month month | The month to set this Date's month to.

    Throws:
    DateTimeException if the given month is not a valid month or if the current day would not be valid in the given month.

  const pure nothrow @property ubyte day();
    Day of a Gregorian Month.

    Examples:

        assert(Date(1999, 7, 6).day == 6);
        assert(Date(2010, 10, 4).day == 4);
        assert(Date(-7, 4, 5).day == 5);

  pure @property void day(int day);
    Day of a Gregorian Month.

    Parameters:

    int day | The day of the month to set this Date's day to.

    Throws:
    DateTimeException if the given day is not a valid day of the current month.

  pure nothrow void add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years");
    Adds the given number of years or months to this Date. A negative number will subtract.

    Note that if day overflow is allowed, and the date with the adjusted year/month overflows the number of days in the new month, then the month will be incremented by one, and the day set to the number of days overflowed. (e.g. if the day were 31 and the new month were June, then the month would be incremented to July, and the new day would be 1). If day overflow is not allowed, then the day will be set to the last valid day in the month (e.g. June 31st would become June 30th).

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this Date.
    AllowDayOverflow allowOverflow | Whether the day should be allowed to overflow, causing the month to increment.

    Examples:

        auto d1 = Date(2010, 1, 1);
        d1.add!"months"(11);
        assert(d1 == Date(2010, 12, 1));

        auto d2 = Date(2010, 1, 1);
        d2.add!"months"(-11);
        assert(d2 == Date(2009, 2, 1));

        auto d3 = Date(2000, 2, 29);
        d3.add!"years"(1);
        assert(d3 == Date(2001, 3, 1));

        auto d4 = Date(2000, 2, 29);
        d4.add!"years"(1, AllowDayOverflow.no);
        assert(d4 == Date(2001, 2, 28));

  pure nothrow void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years");
    Adds the given number of years or months to this Date. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. Rolling a Date 12 months gets the exact same Date. However, the days can still be affected due to the differing number of days in each month.

    Because there are no units larger than years, there is no difference between adding and rolling years.

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this Date.

    Examples:

        auto d1 = Date(2010, 1, 1);
        d1.roll!"months"(1);
        assert(d1 == Date(2010, 2, 1));

        auto d2 = Date(2010, 1, 1);
        d2.roll!"months"(-1);
        assert(d2 == Date(2010, 12, 1));

        auto d3 = Date(1999, 1, 29);
        d3.roll!"months"(1);
        assert(d3 == Date(1999, 3, 1));

        auto d4 = Date(1999, 1, 29);
        d4.roll!"months"(1, AllowDayOverflow.no);
        assert(d4 == Date(1999, 2, 28));

        auto d5 = Date(2000, 2, 29);
        d5.roll!"years"(1);
        assert(d5 == Date(2001, 3, 1));

        auto d6 = Date(2000, 2, 29);
        d6.roll!"years"(1, AllowDayOverflow.no);
        assert(d6 == Date(2001, 2, 28));

  pure nothrow void roll(string units)(long days) if (units == "days");
    Adds the given number of units to this Date. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. For instance, rolling a Date one year's worth of days gets the exact same Date.

    The only accepted units are "days".

    Parameters:

    units | The units to add. Must be "days".
    value | The number of days to add to this Date.

    Examples:

        auto d = Date(2010, 1, 1);
        d.roll!"days"(1);
        assert(d == Date(2010, 1, 2));
        d.roll!"days"(365);
        assert(d == Date(2010, 1, 26));
        d.roll!"days"(-32);
        assert(d == Date(2010, 1, 25));

  const pure nothrow Date opBinary(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this Date.

    The legal types of arithmetic for Date using this operator are

    Date | + | duration | --> | Date
    Date | - | duration | --> | Date

    Parameters:

    D duration | The duration to add to or subtract from this Date.

  pure nothrow Date opOpAssign(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this Date, as well as assigning the result to this Date.

    The legal types of arithmetic for Date using this operator are

    Date | + | duration | --> | Date
    Date | - | duration | --> | Date

    Parameters:

    D duration | The duration to add to or subtract from this Date.

  const pure nothrow Duration opBinary(string op)(in Date rhs) if (op == "-");
    Gives the difference between two Dates.

    The legal types of arithmetic for Date using this operator are

    Date | - | Date | --> | duration

  const pure nothrow int diffMonths(in Date rhs);
    Returns the difference between the two Dates in months.

    To get the difference in years, subtract the year property of two SysTimes. To get the difference in days or weeks, subtract the SysTimes themselves and use the Duration that results. Because converting between months and smaller units requires a specific date (which Durations don't have), getting the difference in months requires some math using both the year and month properties, so this is a convenience function for getting the difference in months.

    Note that the number of days in the months or how far into the month either Date is is irrelevant. It is the difference in the month property combined with the difference in years * 12. So, for instance, December 31st and January 1st are one month apart just as December 1st and January 31st are one month apart.

    Parameters:

    Date rhs | The Date to subtract from this one.

    Examples:

        assert(Date(1999, 2, 1).diffMonths(Date(1999, 1, 31)) == 1);
        assert(Date(1999, 1, 31).diffMonths(Date(1999, 2, 1)) == -1);
        assert(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1)) == 2);
        assert(Date(1999, 1, 1).diffMonths(Date(1999, 3, 31)) == -2);

  const pure nothrow @property bool isLeapYear();
    Whether this Date is in a leap year.

  const pure nothrow @property DayOfWeek dayOfWeek();
    Day of the week this Date is on.

  const pure nothrow @property ushort dayOfYear();
    Day of the year this Date is on.

    Examples:

        assert(Date(1999, 1, 1).dayOfYear == 1);
        assert(Date(1999, 12, 31).dayOfYear == 365);
        assert(Date(2000, 12, 31).dayOfYear == 366);

  pure @property void dayOfYear(int day);
    Day of the year.

    Parameters:

    int day | The day of the year to set which day of the year this Date is on.

    Throws:
    DateTimeException if the given day is an invalid day of the year.

  const pure nothrow @property int dayOfGregorianCal();
    The Xth day of the Gregorian Calendar that this Date is on.

    Examples:

        assert(Date(1, 1, 1).dayOfGregorianCal == 1);
        assert(Date(1, 12, 31).dayOfGregorianCal == 365);
        assert(Date(2, 1, 1).dayOfGregorianCal == 366);

        assert(Date(0, 12, 31).dayOfGregorianCal == 0);
        assert(Date(0, 1, 1).dayOfGregorianCal == -365);
        assert(Date(-1, 12, 31).dayOfGregorianCal == -366);

        assert(Date(2000, 1, 1).dayOfGregorianCal == 730_120);
        assert(Date(2010, 12, 31).dayOfGregorianCal == 734_137);

  pure nothrow @property void dayOfGregorianCal(int day);
    The Xth day of the Gregorian Calendar that this Date is on.

    Parameters:

    int day | The day of the Gregorian Calendar to set this Date to.

    Examples:

        auto date = Date.init;
        date.dayOfGregorianCal = 1;
        assert(date == Date(1, 1, 1));

        date.dayOfGregorianCal = 365;
        assert(date == Date(1, 12, 31));

        date.dayOfGregorianCal = 366;
        assert(date == Date(2, 1, 1));

        date.dayOfGregorianCal = 0;
        assert(date == Date(0, 12, 31));

        date.dayOfGregorianCal = -365;
        assert(date == Date(-0, 1, 1));

        date.dayOfGregorianCal = -366;
        assert(date == Date(-1, 12, 31));

        date.dayOfGregorianCal = 730_120;
        assert(date == Date(2000, 1, 1));

        date.dayOfGregorianCal = 734_137;
        assert(date == Date(2010, 12, 31));

  const pure nothrow @property ubyte isoWeek();
    The ISO 8601 week of the year that this Date is in.

    See Also:
    ISO Week Date

  const pure nothrow @property Date endOfMonth();
    Date for the last day in the month that this Date is in.

    Examples:

        assert(Date(1999, 1, 6).endOfMonth == Date(1999, 1, 31));
        assert(Date(1999, 2, 7).endOfMonth == Date(1999, 2, 28));
        assert(Date(2000, 2, 7).endOfMonth == Date(1999, 2, 29));
        assert(Date(2000, 6, 4).endOfMonth == Date(1999, 6, 30));

  const pure nothrow @property ubyte daysInMonth();
    The last day in the month that this Date is in.

    Examples:

        assert(Date(1999, 1, 6).daysInMonth == 31);
        assert(Date(1999, 2, 7).daysInMonth == 28);
        assert(Date(2000, 2, 7).daysInMonth == 29);
        assert(Date(2000, 6, 4).daysInMonth == 30);

  const pure nothrow @property bool isAD();
    Whether the current year is a date in A.D.

    Examples:

        assert(Date(1, 1, 1).isAD);
        assert(Date(2010, 12, 31).isAD);
        assert(!Date(0, 12, 31).isAD);
        assert(!Date(-2010, 1, 1).isAD);

  const pure nothrow @property long julianDay();
    The julian day for this Date at noon (since the julian day changes at noon).

  const pure nothrow @property long modJulianDay();
    The modified julian day for any time on this date (since, the modified julian day changes at midnight).

  const nothrow string toISOString();
    Converts this Date to a string with the format YYYYMMDD.

    Examples:

        assert(Date(2010, 7, 4).toISOString() == "20100704");
        assert(Date(1998, 12, 25).toISOString() == "19981225");
        assert(Date(0, 1, 5).toISOString() == "00000105");
        assert(Date(-4, 1, 5).toISOString() == "-00040105");

  const nothrow string toISOExtString();
    Converts this Date to a string with the format YYYY-MM-DD.

    Examples:

        assert(Date(2010, 7, 4).toISOExtString() == "2010-07-04");
        assert(Date(1998, 12, 25).toISOExtString() == "1998-12-25");
        assert(Date(0, 1, 5).toISOExtString() == "0000-01-05");
        assert(Date(-4, 1, 5).toISOExtString() == "-0004-01-05");

  const nothrow string toSimpleString();
    Converts this Date to a string with the format YYYY-Mon-DD.

    Examples:

        assert(Date(2010, 7, 4).toSimpleString() == "2010-Jul-04");
        assert(Date(1998, 12, 25).toSimpleString() == "1998-Dec-25");
        assert(Date(0, 1, 5).toSimpleString() == "0000-Jan-05");
        assert(Date(-4, 1, 5).toSimpleString() == "-0004-Jan-05");

  const nothrow string toString();
    Converts this Date to a string.

  Date fromISOString(S)(in S isoString) if (isSomeString!S);
    Creates a Date from a string with the format YYYYMMDD. Whitespace is stripped from the given string.

    Parameters:

    S isoString | A string formatted in the ISO format for dates.

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting Date would not be valid.

    Examples:

        assert(Date.fromISOString("20100704") == Date(2010, 7, 4));
        assert(Date.fromISOString("19981225") == Date(1998, 12, 25));
        assert(Date.fromISOString("00000105") == Date(0, 1, 5));
        assert(Date.fromISOString("-00040105") == Date(-4, 1, 5));
        assert(Date.fromISOString(" 20100704 ") == Date(2010, 7, 4));

  Date fromISOExtString(S)(in S isoExtString) if (isSomeString!S);
    Creates a Date from a string with the format YYYY-MM-DD. Whitespace is stripped from the given string.

    Parameters:

    S isoExtString | A string formatted in the ISO Extended format for dates.

    Throws:
    DateTimeException if the given string is not in the ISO Extended format or if the resulting Date would not be valid.

    Examples:

        assert(Date.fromISOExtString("2010-07-04") == Date(2010, 7, 4));
        assert(Date.fromISOExtString("1998-12-25") == Date(1998, 12, 25));
        assert(Date.fromISOExtString("0000-01-05") == Date(0, 1, 5));
        assert(Date.fromISOExtString("-0004-01-05") == Date(-4, 1, 5));
        assert(Date.fromISOExtString(" 2010-07-04 ") == Date(2010, 7, 4));

  Date fromSimpleString(S)(in S simpleString) if (isSomeString!S);
    Creates a Date from a string with the format YYYY-Mon-DD. Whitespace is stripped from the given string.

    Parameters:

    S simpleString | A string formatted in the way that toSimpleString formats dates.

    Throws:
    DateTimeException if the given string is not in the correct format or if the resulting Date would not be valid.

    Examples:

        assert(Date.fromSimpleString("2010-Jul-04") == Date(2010, 7, 4));
        assert(Date.fromSimpleString("1998-Dec-25") == Date(1998, 12, 25));
        assert(Date.fromSimpleString("0000-Jan-05") == Date(0, 1, 5));
        assert(Date.fromSimpleString("-0004-Jan-05") == Date(-4, 1, 5));
        assert(Date.fromSimpleString(" 2010-Jul-04 ") == Date(2010, 7, 4));

  static pure nothrow @property Date min();
    Returns the Date farthest in the past which is representable by Date.

  static pure nothrow @property Date max();
    Returns the Date farthest in the future which is representable by Date.

struct TimeOfDay;
  Represents a time of day with hours, minutes, and seconds. It uses 24 hour time.

  pure this(int hour, int minute, int second = 0);
    Parameters:

    int hour | Hour of the day [0 - 24).
    int minute | Minute of the hour [0 - 60).
    int second | Second of the minute [0 - 60).

    Throws:
    DateTimeException if the resulting TimeOfDay would be not be valid.

  const pure nothrow int opCmp(in TimeOfDay rhs);
    Compares this TimeOfDay with the given TimeOfDay.

    Returns:

    this < rhs | < 0
    this == rhs | 0
    this > rhs | > 0

  const pure nothrow @property ubyte hour();
    Hours passed midnight.

  pure @property void hour(int hour);
    Hours passed midnight.

    Parameters:

    int hour | The hour of the day to set this TimeOfDay's hour to.

    Throws:
    DateTimeException if the given hour would result in an invalid TimeOfDay.

  const pure nothrow @property ubyte minute();
    Minutes passed the hour.

  pure @property void minute(int minute);
    Minutes passed the hour.

    Parameters:

    int minute | The minute to set this TimeOfDay's minute to.

    Throws:
    DateTimeException if the given minute would result in an invalid TimeOfDay.

  const pure nothrow @property ubyte second();
    Seconds passed the minute.

  pure @property void second(int second);
    Seconds passed the minute.

    Parameters:

    int second | The second to set this TimeOfDay's second to.

    Throws:
    DateTimeException if the given second would result in an invalid TimeOfDay.

  pure nothrow void roll(string units)(long value) if (units == "hours");
    Adds the given number of units to this TimeOfDay. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. For instance, rolling a TimeOfDay one hours's worth of minutes gets the exact same TimeOfDay.

    Accepted units are "hours", "minutes", and "seconds".

    Parameters:

    units | The units to add.
    long value | The number of units to add to this TimeOfDay.

    Examples:

        auto tod1 = TimeOfDay(7, 12, 0);
        tod1.roll!"hours"(1);
        assert(tod1 == TimeOfDay(8, 12, 0));

        auto tod2 = TimeOfDay(7, 12, 0);
        tod2.roll!"hours"(-1);
        assert(tod2 == TimeOfDay(6, 12, 0));

        auto tod3 = TimeOfDay(23, 59, 0);
        tod3.roll!"minutes"(1);
        assert(tod3 == TimeOfDay(23, 0, 0));

        auto tod4 = TimeOfDay(0, 0, 0);
        tod4.roll!"minutes"(-1);
        assert(tod4 == TimeOfDay(0, 59, 0));

        auto tod5 = TimeOfDay(23, 59, 59);
        tod5.roll!"seconds"(1);
        assert(tod5 == TimeOfDay(23, 59, 0));

        auto tod6 = TimeOfDay(0, 0, 0);
        tod6.roll!"seconds"(-1);
        assert(tod6 == TimeOfDay(0, 0, 59));

  const pure nothrow TimeOfDay opBinary(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this TimeOfDay.

    The legal types of arithmetic for TimeOfDay using this operator are

    TimeOfDay | + | duration | --> | TimeOfDay
    TimeOfDay | - | duration | --> | TimeOfDay

    Parameters:

    D duration | The duration to add to or subtract from this TimeOfDay.

  pure nothrow TimeOfDay opOpAssign(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this TimeOfDay, as well as assigning the result to this TimeOfDay.

    The legal types of arithmetic for TimeOfDay using this operator are

    TimeOfDay | + | duration | --> | TimeOfDay
    TimeOfDay | - | duration | --> | TimeOfDay

    Parameters:

    D duration | The duration to add to or subtract from this TimeOfDay.

  const pure nothrow Duration opBinary(string op)(in TimeOfDay rhs) if (op == "-");
    Gives the difference between two TimeOfDays.

    The legal types of arithmetic for TimeOfDay using this operator are

    TimeOfDay | - | TimeOfDay | --> | duration

    Parameters:

    TimeOfDay rhs | The TimeOfDay to subtract from this one.

  const nothrow string toISOString();
    Converts this TimeOfDay to a string with the format HHMMSS.

    Examples:

        assert(TimeOfDay(0, 0, 0).toISOString() == "000000");
        assert(TimeOfDay(12, 30, 33).toISOString() == "123033");

  const nothrow string toISOExtString();
    Converts this TimeOfDay to a string with the format HH:MM:SS.

    Examples:

        assert(TimeOfDay(0, 0, 0).toISOExtString() == "000000");
        assert(TimeOfDay(12, 30, 33).toISOExtString() == "123033");

  const nothrow string toString();
    Converts this TimeOfDay to a string.

  TimeOfDay fromISOString(S)(in S isoString) if (isSomeString!S);
    Creates a TimeOfDay from a string with the format HHMMSS. Whitespace is stripped from the given string.

    Parameters:

    S isoString | A string formatted in the ISO format for times.

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting TimeOfDay would not be valid.

    Examples:

        assert(TimeOfDay.fromISOString("000000") == TimeOfDay(0, 0, 0));
        assert(TimeOfDay.fromISOString("123033") == TimeOfDay(12, 30, 33));
        assert(TimeOfDay.fromISOString(" 123033 ") == TimeOfDay(12, 30, 33));

  TimeOfDay fromISOExtString(S)(in S isoExtString) if (isSomeString!S);
    Creates a TimeOfDay from a string with the format HH:MM:SS. Whitespace is stripped from the given string.

    Parameters:

    isoString | A string formatted in the ISO Extended format for times.

    Throws:
    DateTimeException if the given string is not in the ISO Extended format or if the resulting TimeOfDay would not be valid.

    Examples:

        assert(TimeOfDay.fromISOExtString("00:00:00") == TimeOfDay(0, 0, 0));
        assert(TimeOfDay.fromISOExtString("12:30:33") == TimeOfDay(12, 30, 33));
        assert(TimeOfDay.fromISOExtString(" 12:30:33 ") == TimeOfDay(12, 30, 33));

  static pure nothrow @property TimeOfDay min();
    Returns midnight.

  static pure nothrow @property TimeOfDay max();
    Returns one second short of midnight.

struct DateTime;
  Combines the Date and TimeOfDay structs to give an object which holds both the date and the time. It is optimized for calendar-based operations and has no concept of time zone. For an object which is optimized for time operations based on the system time, use SysTime. SysTime has a concept of time zone and has much higher precision (hnsecs). DateTime is intended primarily for calendar-based uses rather than precise time operations.

  pure nothrow this(in Date date, in TimeOfDay tod = TimeOfDay.init);
    Parameters:

    Date date | The date portion of DateTime.
    TimeOfDay tod | The time portion of DateTime.

  pure this(int year, int month, int day, int hour = 0, int minute = 0, int second = 0);
    Parameters:

    int year | The year portion of the date.
    int month | The month portion of the date.
    int day | The day portion of the date.
    int hour | The hour portion of the time;
    int minute | The minute portion of the time;
    int second | The second portion of the time;

  const pure nothrow int opCmp(in DateTime rhs);
    Compares this DateTime with the given DateTime..

    Returns:

    this < rhs | < 0
    this == rhs | 0
    this > rhs | > 0

  const pure nothrow @property Date date();
    The date portion of DateTime.

  pure nothrow @property void date(in Date date);
    The date portion of DateTime.

    Parameters:

    Date date | The Date to set this DateTime's date portion to.

  const pure nothrow @property TimeOfDay timeOfDay();
    The time portion of DateTime.

  pure nothrow @property void timeOfDay(in TimeOfDay tod);
    The time portion of DateTime.

    Parameters:

    TimeOfDay tod | The TimeOfDay to set this DateTime's time portion to.

  const pure nothrow @property short year();
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

  pure @property void year(int year);
    Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.

    Parameters:

    int year | The year to set this DateTime's year to.

    Throws:
    DateTimeException if the new year is not a leap year and if the resulting date would be on February 29th.

    Examples:

        assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).year == 1999);
        assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).year == 2010);
        assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).year == -7);

  const pure @property short yearBC();
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Throws:
    DateTimeException if isAD is true.

    Examples:

        assert(DateTime(Date(0, 1, 1), TimeOfDay(12, 30, 33)).yearBC == 1);
        assert(DateTime(Date(-1, 1, 1), TimeOfDay(10, 7, 2)).yearBC == 2);
        assert(DateTime(Date(-100, 1, 1), TimeOfDay(4, 59, 0)).yearBC == 101);

  pure @property void yearBC(int year);
    Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.

    Parameters:

    int year | The year B.C. to set this DateTime's year to.

    Throws:
    DateTimeException if a non-positive value is given.

    Examples:

        auto dt = DateTime(Date(2010, 1, 1), TimeOfDay(7, 30, 0));
        dt.yearBC = 1;
        assert(dt == DateTime(Date(0, 1, 1), TimeOfDay(7, 30, 0)));

        dt.yearBC = 10;
        assert(dt == DateTime(Date(-9, 1, 1), TimeOfDay(7, 30, 0)));

  const pure nothrow @property Month month();
    Month of a Gregorian Year.

    Examples:

        assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).month == 7);
        assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).month == 10);
        assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).month == 4);

  pure @property void month(Month month);
    Month of a Gregorian Year.

    Parameters:

    Month month | The month to set this DateTime's month to.

    Throws:
    DateTimeException if the given month is not a valid month.

  const pure nothrow @property ubyte day();
    Day of a Gregorian Month.

    Examples:

        assert(DateTime(Date(1999, 7, 6), TimeOfDay(9, 7, 5)).day == 6);
        assert(DateTime(Date(2010, 10, 4), TimeOfDay(0, 0, 30)).day == 4);
        assert(DateTime(Date(-7, 4, 5), TimeOfDay(7, 45, 2)).day == 5);

  pure @property void day(int day);
    Day of a Gregorian Month.

    Parameters:

    int day | The day of the month to set this DateTime's day to.

    Throws:
    DateTimeException if the given day is not a valid day of the current month.

  const pure nothrow @property ubyte hour();
    Hours passed midnight.

  pure @property void hour(int hour);
    Hours passed midnight.

    Parameters:

    int hour | The hour of the day to set this DateTime's hour to.

    Throws:
    DateTimeException if the given hour would result in an invalid DateTime.

  const pure nothrow @property ubyte minute();
    Minutes passed the hour.

  pure @property void minute(int minute);
    Minutes passed the hour.

    Parameters:

    int minute | The minute to set this DateTime's minute to.

    Throws:
    DateTimeException if the given minute would result in an invalid DateTime.

  const pure nothrow @property ubyte second();
    Seconds passed the minute.

  pure @property void second(int second);
    Seconds passed the minute.

    Parameters:

    int second | The second to set this DateTime's second to.

    Throws:
    DateTimeException if the given seconds would result in an invalid DateTime.

  pure nothrow void add(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years" || units == "months");
    Adds the given number of years or months to this DateTime. A negative number will subtract.

    Note that if day overflow is allowed, and the date with the adjusted year/month overflows the number of days in the new month, then the month will be incremented by one, and the day set to the number of days overflowed. (e.g. if the day were 31 and the new month were June, then the month would be incremented to July, and the new day would be 1). If day overflow is not allowed, then the day will be set to the last valid day in the month (e.g. June 31st would become June 30th).

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this DateTime.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow, causing the month to increment.

    Examples:

        auto dt1 = DateTime(2010, 1, 1, 12, 30, 33);
        dt1.add!"months"(11);
        assert(dt1 == DateTime(2010, 12, 1, 12, 30, 33));

        auto dt2 = DateTime(2010, 1, 1, 12, 30, 33);
        dt2.add!"months"(-11);
        assert(dt2 == DateTime(2009, 2, 1, 12, 30, 33));

        auto dt3 = DateTime(2000, 2, 29, 12, 30, 33);
        dt3.add!"years"(1);
        assert(dt3 == DateTime(2001, 3, 1, 12, 30, 33));

        auto dt4 = DateTime(2000, 2, 29, 12, 30, 33);
        dt4.add!"years"(1, AllowDayOverflow.no);
        assert(dt4 == DateTime(2001, 2, 28, 12, 30, 33));

  pure nothrow void roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years" || units == "months");
    Adds the given number of years or months to this DateTime. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. Rolling a DateTime 12 months gets the exact same DateTime. However, the days can still be affected due to the differing number of days in each month.

    Because there are no units larger than years, there is no difference between adding and rolling years.

    Parameters:

    units | The type of units to add ("years" or "months").
    long value | The number of months or years to add to this DateTime.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow, causing the month to increment.

    Examples:

        auto dt1 = DateTime(2010, 1, 1, 12, 33, 33);
        dt1.roll!"months"(1);
        assert(dt1 == DateTime(2010, 2, 1, 12, 33, 33));

        auto dt2 = DateTime(2010, 1, 1, 12, 33, 33);
        dt2.roll!"months"(-1);
        assert(dt2 == DateTime(2010, 12, 1, 12, 33, 33));

        auto dt3 = DateTime(1999, 1, 29, 12, 33, 33);
        dt3.roll!"months"(1);
        assert(dt3 == DateTime(1999, 3, 1, 12, 33, 33));

        auto dt4 = DateTime(1999, 1, 29, 12, 33, 33);
        dt4.roll!"months"(1, AllowDayOverflow.no);
        assert(dt4 == DateTime(1999, 2, 28, 12, 33, 33));

        auto dt5 = DateTime(2000, 2, 29, 12, 30, 33);
        dt5.roll!"years"(1);
        assert(dt5 == DateTime(2001, 3, 1, 12, 30, 33));

        auto dt6 = DateTime(2000, 2, 29, 12, 30, 33);
        dt6.roll!"years"(1, AllowDayOverflow.no);
        assert(dt6 == DateTime(2001, 2, 28, 12, 30, 33));

  pure nothrow void roll(string units)(long days) if (units == "days");
    Adds the given number of units to this DateTime. A negative number will subtract.

    The difference between rolling and adding is that rolling does not affect larger units. For instance, rolling a DateTime one year's worth of days gets the exact same DateTime.

    Accepted units are "days", "minutes", "hours", "minutes", and "seconds".

    Parameters:

    units | The units to add.
    value | The number of units to add to this DateTime.

    Examples:

        auto dt1 = DateTime(2010, 1, 1, 11, 23, 12);
        dt1.roll!"days"(1);
        assert(dt1 == DateTime(2010, 1, 2, 11, 23, 12));
        dt1.roll!"days"(365);
        assert(dt1 == DateTime(2010, 1, 26, 11, 23, 12));
        dt1.roll!"days"(-32);
        assert(dt1 == DateTime(2010, 1, 25, 11, 23, 12));

        auto dt2 = DateTime(2010, 7, 4, 12, 0, 0);
        dt2.roll!"hours"(1);
        assert(dt2 == DateTime(2010, 7, 4, 13, 0, 0));

        auto dt3 = DateTime(2010, 1, 1, 0, 0, 0);
        dt3.roll!"seconds"(-1);
        assert(dt3 == DateTime(2010, 1, 1, 0, 0, 59));

  const pure nothrow DateTime opBinary(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this DateTime.

    The legal types of arithmetic for DateTime using this operator are

    DateTime | + | duration | --> | DateTime
    DateTime | - | duration | --> | DateTime

    Parameters:

    D duration | The duration to add to or subtract from this DateTime.

  pure nothrow DateTime opOpAssign(string op, D)(in D duration) if ((op == "+" || op == "-") && (is(Unqual!D == Duration) || is(Unqual!D == TickDuration)));
    Gives the result of adding or subtracting a duration from this DateTime, as well as assigning the result to this DateTime.

    The legal types of arithmetic for DateTime using this operator are

    DateTime | + | duration | --> | DateTime
    DateTime | - | duration | --> | DateTime

    Parameters:

    D duration | The duration to add to or subtract from this DateTime.

  const pure nothrow Duration opBinary(string op)(in DateTime rhs) if (op == "-");
    Gives the difference between two DateTimes.

    The legal types of arithmetic for DateTime using this operator are

    DateTime | - | DateTime | --> | duration

  const pure nothrow int diffMonths(in DateTime rhs);
    Returns the difference between the two DateTimes in months.

    To get the difference in years, subtract the year property of two SysTimes. To get the difference in days or weeks, subtract the SysTimes themselves and use the Duration that results. Because converting between months and smaller units requires a specific date (which Durations don't have), getting the difference in months requires some math using both the year and month properties, so this is a convenience function for getting the difference in months.

    Note that the number of days in the months or how far into the month either date is is irrelevant. It is the difference in the month property combined with the difference in years * 12. So, for instance, December 31st and January 1st are one month apart just as December 1st and January 31st are one month apart.

    Parameters:

    DateTime rhs | The DateTime to subtract from this one.

    Examples:

        assert(DateTime(1999, 2, 1, 12, 2, 3).diffMonths(
                    DateTime(1999, 1, 31, 23, 59, 59)) == 1);

        assert(DateTime(1999, 1, 31, 0, 0, 0).diffMonths(
                    DateTime(1999, 2, 1, 12, 3, 42)) == -1);

        assert(DateTime(1999, 3, 1, 5, 30, 0).diffMonths(
                    DateTime(1999, 1, 1, 2, 4, 7)) == 2);

        assert(DateTime(1999, 1, 1, 7, 2, 4).diffMonths(
                    DateTime(1999, 3, 31, 0, 30, 58)) == -2);

  const pure nothrow @property bool isLeapYear();
    Whether this DateTime is in a leap year.

  const pure nothrow @property DayOfWeek dayOfWeek();
    Day of the week this DateTime is on.

  const pure nothrow @property ushort dayOfYear();
    Day of the year this DateTime is on.

    Examples:

        assert(DateTime(Date(1999, 1, 1), TimeOfDay(12, 22, 7)).dayOfYear == 1);
        assert(DateTime(Date(1999, 12, 31), TimeOfDay(7, 2, 59)).dayOfYear == 365);
        assert(DateTime(Date(2000, 12, 31), TimeOfDay(21, 20, 0)).dayOfYear == 366);

  pure @property void dayOfYear(int day);
    Day of the year.

    Parameters:

    int day | The day of the year to set which day of the year this DateTime is on.

  const pure nothrow @property int dayOfGregorianCal();
    The Xth day of the Gregorian Calendar that this DateTime is on.

    Examples:

        assert(DateTime(Date(1, 1, 1), TimeOfDay(0, 0, 0)).dayOfGregorianCal ==
               1);
        assert(DateTime(Date(1, 12, 31), TimeOfDay(23, 59, 59)).dayOfGregorianCal ==
               365);
        assert(DateTime(Date(2, 1, 1), TimeOfDay(2, 2, 2)).dayOfGregorianCal ==
               366);

        assert(DateTime(Date(0, 12, 31), TimeOfDay(7, 7, 7)).dayOfGregorianCal ==
               0);
        assert(DateTime(Date(0, 1, 1), TimeOfDay(19, 30, 0)).dayOfGregorianCal ==
               -365);
        assert(DateTime(Date(-1, 12, 31), TimeOfDay(4, 7, 0)).dayOfGregorianCal ==
               -366);

        assert(DateTime(Date(2000, 1, 1), TimeOfDay(9, 30, 20)).dayOfGregorianCal ==
               730_120);
        assert(DateTime(Date(2010, 12, 31), TimeOfDay(15, 45, 50)).dayOfGregorianCal ==
               734_137);

  pure nothrow @property void dayOfGregorianCal(int days);
    The Xth day of the Gregorian Calendar that this DateTime is on. Setting this property does not affect the time portion of DateTime.

    Parameters:

    int days | The day of the Gregorian Calendar to set this DateTime to.

    Examples:

        auto dt = DateTime(Date.init, TimeOfDay(12, 0, 0));
        dt.dayOfGregorianCal = 1;
        assert(dt == DateTime(Date(1, 1, 1), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = 365;
        assert(dt == DateTime(Date(1, 12, 31), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = 366;
        assert(dt == DateTime(Date(2, 1, 1), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = 0;
        assert(dt == DateTime(Date(0, 12, 31), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = -365;
        assert(dt == DateTime(Date(-0, 1, 1), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = -366;
        assert(dt == DateTime(Date(-1, 12, 31), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = 730_120;
        assert(dt == DateTime(Date(2000, 1, 1), TimeOfDay(12, 0, 0)));

        dt.dayOfGregorianCal = 734_137;
        assert(dt == DateTime(Date(2010, 12, 31), TimeOfDay(12, 0, 0)));

  const pure nothrow @property ubyte isoWeek();
    The ISO 8601 week of the year that this DateTime is in.

    See Also:
    ISO Week Date

  const pure nothrow @property DateTime endOfMonth();
    DateTime for the last day in the month that this DateTime is in. The time portion of endOfMonth is always 23:59:59.

    Examples:

        assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).endOfMonth ==
               DateTime(Date(1999, 1, 31), TimeOfDay(23, 59, 59)));

        assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).endOfMonth ==
               DateTime(Date(1999, 2, 28), TimeOfDay(23, 59, 59)));

        assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).endOfMonth ==
               DateTime(Date(2000, 2, 29), TimeOfDay(23, 59, 59)));

        assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).endOfMonth ==
               DateTime(Date(2000, 6, 30), TimeOfDay(23, 59, 59)));

  const pure nothrow @property ubyte daysInMonth();
    The last day in the month that this DateTime is in.

    Examples:

        assert(DateTime(Date(1999, 1, 6), TimeOfDay(0, 0, 0)).daysInMonth == 31);
        assert(DateTime(Date(1999, 2, 7), TimeOfDay(19, 30, 0)).daysInMonth == 28);
        assert(DateTime(Date(2000, 2, 7), TimeOfDay(5, 12, 27)).daysInMonth == 29);
        assert(DateTime(Date(2000, 6, 4), TimeOfDay(12, 22, 9)).daysInMonth == 30);

  const pure nothrow @property bool isAD();
    Whether the current year is a date in A.D.

    Examples:

        assert(DateTime(Date(1, 1, 1), TimeOfDay(12, 7, 0)).isAD);
        assert(DateTime(Date(2010, 12, 31), TimeOfDay(0, 0, 0)).isAD);
        assert(!DateTime(Date(0, 12, 31), TimeOfDay(23, 59, 59)).isAD);
        assert(!DateTime(Date(-2010, 1, 1), TimeOfDay(2, 2, 2)).isAD);

  const pure nothrow @property long julianDay();
    The julian day for this DateTime at the given time. For example, prior to noon, 1996-03-31 would be the julian day number 2450_173, so this function returns 2450_173, while from noon onward, the julian day number would be 2450_174, so this function returns 2450_174.

  const pure nothrow @property long modJulianDay();
    The modified julian day for any time on this date (since, the modified julian day changes at midnight).

  const nothrow string toISOString();
    Converts this DateTime to a string with the format YYYYMMDDTHHMMSS.

    Examples:

        assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOString() ==
               "20100704T070612");

        assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOString() ==
               "19981225T021500");

        assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOString() ==
               "00000105T230959");

        assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOString() ==
               "-00040105T000002");

  const nothrow string toISOExtString();
    Converts this DateTime to a string with the format YYYY-MM-DDTHH:MM:SS.

    Examples:

        assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toISOExtString() ==
               "2010-07-04T07:06:12");

        assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toISOExtString() ==
               "1998-12-25T02:15:00");

        assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toISOExtString() ==
               "0000-01-05T23:09:59");

        assert(DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)).toISOExtString() ==
               "-0004-01-05T00:00:02");

  const nothrow string toSimpleString();
    Converts this DateTime to a string with the format YYYY-Mon-DD HH:MM:SS.

    Examples:

        assert(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toSimpleString() ==
               "2010-Jul-04 07:06:12");

        assert(DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)).toSimpleString() ==
               "1998-Dec-25 02:15:00");

        assert(DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)).toSimpleString() ==
               "0000-Jan-05 23:09:59");

        assert(DateTime(Dte(-4, 1, 5), TimeOfDay(0, 0, 2)).toSimpleString() ==
               "-0004-Jan-05 00:00:02");

  const nothrow string toString();
    Converts this DateTime to a string.

  DateTime fromISOString(S)(in S isoString) if (isSomeString!S);
    Creates a DateTime from a string with the format YYYYMMDDTHHMMSS. Whitespace is stripped from the given string.

    Parameters:

    S isoString | A string formatted in the ISO format for dates and times.

    Throws:
    DateTimeException if the given string is not in the ISO format or if the resulting DateTime would not be valid.

    Examples:

        assert(DateTime.fromISOString("20100704T070612") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));

        assert(DateTime.fromISOString("19981225T021500") ==
               DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));

        assert(DateTime.fromISOString("00000105T230959") ==
               DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));

        assert(DateTime.fromISOString("-00040105T000002") ==
               DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));

        assert(DateTime.fromISOString(" 20100704T070612 ") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));

  DateTime fromISOExtString(S)(in S isoExtString) if (isSomeString!S);
    Creates a DateTime from a string with the format YYYY-MM-DDTHH:MM:SS. Whitespace is stripped from the given string.

    Parameters:

    isoString | A string formatted in the ISO Extended format for dates and times.

    Throws:
    DateTimeException if the given string is not in the ISO Extended format or if the resulting DateTime would not be valid.

    Examples:

        assert(DateTime.fromISOExtString("2010-07-04T07:06:12") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));

        assert(DateTime.fromISOExtString("1998-12-25T02:15:00") ==
               DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));

        assert(DateTime.fromISOExtString("0000-01-05T23:09:59") ==
               DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));

        assert(DateTime.fromISOExtString("-0004-01-05T00:00:02") ==
               DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));

        assert(DateTime.fromISOExtString(" 2010-07-04T07:06:12 ") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));

  DateTime fromSimpleString(S)(in S simpleString) if (isSomeString!S);
    Creates a DateTime from a string with the format YYYY-Mon-DD HH:MM:SS. Whitespace is stripped from the given string.

    Parameters:

    S simpleString | A string formatted in the way that toSimpleString formats dates and times.

    Throws:
    DateTimeException if the given string is not in the correct format or if the resulting DateTime would not be valid.

    Examples:

        assert(DateTime.fromSimpleString("2010-Jul-04 07:06:12") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));
        assert(DateTime.fromSimpleString("1998-Dec-25 02:15:00") ==
               DateTime(Date(1998, 12, 25), TimeOfDay(2, 15, 0)));
        assert(DateTime.fromSimpleString("0000-Jan-05 23:09:59") ==
               DateTime(Date(0, 1, 5), TimeOfDay(23, 9, 59)));
        assert(DateTime.fromSimpleString("-0004-Jan-05 00:00:02") ==
               DateTime(Date(-4, 1, 5), TimeOfDay(0, 0, 2)));
        assert(DateTime.fromSimpleString(" 2010-Jul-04 07:06:12 ") ==
               DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)));

  static pure nothrow @property DateTime min();
    Returns the DateTime farthest in the past which is representable by DateTime.

  static pure nothrow @property DateTime max();
    Returns the DateTime farthest in the future which is representable by DateTime.

struct Interval(TP);
  Represents an interval of time.

  An Interval has a starting point and an end point. The interval of time is therefore the time starting at the starting point up to, but not including, the end point. e.g.

  [January 5th, 2010 - March 10th, 2010)
  [05:00:30 - 12:00:00)
  [1982-01-04T08:59:00 - 2010-07-04T12:00:00)

  A range can be obtained from an Interval, allowing iteration over that interval, with the exact time points which are iterated over depending on the function which generates the range.

  pure this(U)(in TP begin, in U end) if (is(Unqual!TP == Unqual!U));
    Parameters:

    TP begin | The time point which begins the interval.
    U end | The time point which ends (but is not included in) the interval.

    Throws:
    DateTimeException if end is before begin.

    Examples:

        Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));

  pure this(D)(in TP begin, in D duration) if (__traits(compiles, begin + duration));
    Parameters:

    TP begin | The time point which begins the interval.
    D duration | The duration from the starting point to the end point.

    Throws:
    DateTimeException if the resulting end is before begin.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), dur!"years"(3)) ==
               Interval!Date(Date(1996, 1, 2), Date(1999, 1, 2)));

  pure nothrow Interval opAssign(ref const Interval rhs);
    Parameters:

    Interval rhs | The Interval to assign to this one.

  pure nothrow Interval opAssign(Interval rhs);
    Parameters:

    Interval rhs | The Interval to assign to this one.

  const pure nothrow TP begin();
    The starting point of the interval. It is included in the interval.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).begin ==
               Date(1996, 1, 2));

  pure void begin(TP timePoint);
    The starting point of the interval. It is included in the interval.

    Parameters:

    TP timePoint | The time point to set begin to.

    Throws:
    DateTimeException if the resulting interval would be invalid.

  const pure nothrow TP end();
    The end point of the interval. It is excluded from the interval.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).end ==
               Date(2012, 3, 1));

  pure void end(TP timePoint);
    The end point of the interval. It is excluded from the interval.

    Parameters:

    TP timePoint | The time point to set end to.

    Throws:
    DateTimeException if the resulting interval would be invalid.

  const pure nothrow typeof(end - begin) length();
    Returns the duration between begin and end.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).length ==
               dur!"days"(5903));

  const pure nothrow bool empty();
    Whether the interval's length is 0, that is, whether begin == end.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(1996, 1, 2)).empty);
        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).empty);

  const pure bool contains(in TP timePoint);
    Whether the given time point is within this interval.

    Parameters:

    TP timePoint | The time point to check for inclusion in this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Date(1994, 12, 24)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Date(2000, 1, 5)));
        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Date(2012, 3, 1)));

  const pure bool contains(in Interval interval);
    Whether the given interval is completely within this interval.

    Parameters:

    Interval interval | The interval to check for inclusion in this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));

  const pure bool contains(in PosInfInterval!TP interval);
    Whether the given interval is completely within this interval.

    Always returns false (unless this interval is empty), because an interval going to positive infinity can never be contained in a finite interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check for inclusion in this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    PosInfInterval!Date(Date(1999, 5, 4))));

  const pure bool contains(in NegInfInterval!TP interval);
    Whether the given interval is completely within this interval.

    Always returns false (unless this interval is empty), because an interval beginning at negative infinity can never be contained in a finite interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check for inclusion in this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains(
                    NegInfInterval!Date(Date(1996, 5, 4))));

  const pure bool isBefore(in TP timePoint);
    Whether this interval is before the given time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is before it.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Date(1994, 12, 24)));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Date(2000, 1, 5)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Date(2012, 3, 1)));

  const pure bool isBefore(in Interval interval);
    Whether this interval is before the given interval and does not intersect with it.

    Parameters:

    Interval interval | The interval to check for against this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(2012, 3, 1), Date(2013, 5, 1))));

  const pure bool isBefore(in PosInfInterval!TP interval);
    Whether this interval is before the given interval and does not intersect with it.

    Parameters:

    PosInfInterval!TP interval | The interval to check for against this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    PosInfInterval!Date(Date(2013, 3, 7))));

  const pure bool isBefore(in NegInfInterval!TP interval);
    Whether this interval is before the given interval and does not intersect with it.

    Always returns false (unless this interval is empty) because a finite interval can never be before an interval beginning at negative infinity.

    Parameters:

    NegInfInterval!TP interval | The interval to check for against this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore(
                    NegInfInterval!Date(Date(1996, 5, 4))));

  const pure bool isAfter(in TP timePoint);
    Whether this interval is after the given time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is after it.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Date(1994, 12, 24)));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Date(2000, 1, 5)));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Date(2012, 3, 1)));

  const pure bool isAfter(in Interval interval);
    Whether this interval is after the given interval and does not intersect it.

    Parameters:

    Interval interval | The interval to check against this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));

  const pure bool isAfter(in PosInfInterval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Always returns false (unless this interval is empty) because a finite interval can never be after an interval going to positive infinity.

    Parameters:

    PosInfInterval!TP interval | The interval to check against this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    PosInfInterval!Date(Date(1999, 5, 4))));

  const pure bool isAfter(in NegInfInterval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Parameters:

    NegInfInterval!TP interval | The interval to check against this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter(
                    NegInfInterval!Date(Date(1996, 1, 2))));

  const pure bool intersects(in Interval interval);
    Whether the given interval overlaps this interval.

    Parameters:

    Interval interval | The interval to check for intersection with this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));

  const pure bool intersects(in PosInfInterval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check for intersection with this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure bool intersects(in NegInfInterval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check for intersection with this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    NegInfInterval!Date(Date(1996, 1, 2))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects(
                    NegInfInterval!Date(Date(2000, 1, 2))));

  const Interval intersection(in Interval interval);
    Returns the intersection of two intervals

    Parameters:

    Interval interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect or if either interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
               Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));

  const Interval intersection(in PosInfInterval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    PosInfInterval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect or if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    PosInfInterval!Date(Date(1999, 1, 12))) ==
               Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));

  const Interval intersection(in NegInfInterval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    NegInfInterval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect or if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    NegInfInterval!Date(Date(1999, 7, 6))) ==
               Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));

  const pure bool isAdjacent(in Interval interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    Interval interval | The interval to check whether its adjecent to this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(1990, 7, 6), Date(1996, 1, 2))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(2012, 3, 1), Date(2013, 9, 17))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(1989, 3, 1), Date(2012, 3, 1))));

  const pure bool isAdjacent(in PosInfInterval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check whether its adjecent to this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure bool isAdjacent(in NegInfInterval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check whether its adjecent to this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    NegInfInterval!Date(Date(1996, 1, 2))));

        assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent(
                    NegInfInterval!Date(Date(2000, 1, 2))));

  const Interval merge(in Interval interval);
    Returns the union of two intervals

    Parameters:

    Interval interval | The interval to merge with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect and are not adjacent or if either interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));

  const PosInfInterval!TP merge(in PosInfInterval!TP interval);
    Returns the union of two intervals

    Parameters:

    PosInfInterval!TP interval | The interval to merge with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect and are not adjacent or if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    PosInfInterval!Date(Date(2012, 3, 1))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  const NegInfInterval!TP merge(in NegInfInterval!TP interval);
    Returns the union of two intervals

    Parameters:

    NegInfInterval!TP interval | The interval to merge with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect and are not adjacent or if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    NegInfInterval!Date(Date(1996, 1, 2))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               NegInfInterval!Date(Date(2013, 1 , 12)));

  const pure Interval span(in Interval interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    Interval interval | The interval to create a span together with this interval.

    Throws:
    DateTimeException if either interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    Interval!Date(Date(1990, 7, 6), Date(1991, 1, 8))) ==
               Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));

  const pure PosInfInterval!TP span(in PosInfInterval!TP interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    PosInfInterval!TP interval | The interval to create a span together with this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    PosInfInterval!Date(Date(2050, 1, 1))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  const pure NegInfInterval!TP span(in NegInfInterval!TP interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    NegInfInterval!TP interval | The interval to create a span together with this interval.

    Throws:
    DateTimeException if this interval is empty.

    Examples:

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    NegInfInterval!Date(Date(1602, 5, 21))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               NegInfInterval!Date(Date(2013, 1 , 12)));

  pure void shift(D)(D duration) if (__traits(compiles, begin + duration));
    Shifts the interval forward or backwards in time by the given duration (a positive duration shifts the interval forward; a negative duration shifts it backward). Effectively, it does begin += duration and end += duration.

    Parameters:

    D duration | The duration to shift the interval by.

    Throws:
    DateTimeException this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));
        auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));

        interval1.shift(dur!"days"(50));
        assert(interval1 == Interval!Date(Date(1996, 2, 21), Date(2012, 5, 25)));

        interval2.shift(dur!"days"(-50));
        assert(interval2 == Interval!Date(Date(1995, 11, 13), Date(2012, 2, 15)));

  void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (isIntegral!T);
    Shifts the interval forward or backwards in time by the given number of years and/or months (a positive number of years and months shifts the interval forward; a negative number shifts it backward). It adds the years the given years and months to both begin and end. It effectively calls add!"years"() and then add!"months"() on begin and end with the given number of years and months.

    Parameters:

    T years | The number of years to shift the interval by.
    T months | The number of months to shift the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on begin and end, causing their month to increment.

    Throws:
    DateTimeException if this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
        auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));

        interval1.shift(2);
        assert(interval1 == Interval!Date(Date(1998, 1, 2), Date(2014, 3, 1)));

        interval2.shift(-2);
        assert(interval2 == Interval!Date(Date(1994, 1, 2), Date(2010, 3, 1)));

  pure void expand(D)(D duration, Direction dir = Direction.both) if (__traits(compiles, begin + duration));
    Expands the interval forwards and/or backwards in time. Effectively, it does begin -= duration and/or end += duration. Whether it expands forwards and/or backwards in time is determined by dir.

    Parameters:

    D duration | The duration to expand the interval by.
    Direction dir | The direction in time to expand the interval.

    Throws:
    DateTimeException this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
        auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));

        interval1.expand(2);
        assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));

        interval2.expand(-2);
        assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));

  void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes, Direction dir = Direction.both) if (isIntegral!T);
    Expands the interval forwards and/or backwards in time. Effectively, it subtracts the given number of months/years from begin and adds them to end. Whether it expands forwards and/or backwards in time is determined by dir.

    Parameters:

    T years | The number of years to expand the interval by.
    T months | The number of months to expand the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on begin and end, causing their month to increment.

    Throws:
    DateTimeException if this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
        auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));

        interval1.expand(2);
        assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));

        interval2.expand(-2);
        assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));

  const IntervalRange!(TP, Direction.fwd) fwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no);
    Returns a range which iterates forward over the interval, starting at begin, using func to generate each successive time point.

    The range's front is the interval's begin. func is used to generate the next front when popFront is called. If popFirst is PopFirst.yes, then popFront is called before the range is returned (so that front is a time point which func would generate).

    If func ever generates a time point less than or equal to the current front of the range, then a DateTimeException will be thrown. The range will be empty and iteration complete when func generates a time point equal to or beyond the end of the interval.

    There are helper functions in this module which generate common delegates to pass to fwdRange. Their documentation starts with "Range-generating function," making them easily searchable.

    Parameters:

    TP delegate(in TP) func | The function used to generate the time points of the range over the interval.
    PopFirst popFirst | Whether popFront should be called on the range before returning it.

    Throws:
    DateTimeException if this interval is empty.

    Warning:
    func must be logically pure. Ideally, func would be a function pointer to a pure function, but forcing func to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass to fwdRange, func must be a delegate.

    If func retains state which changes as it is called, then some algorithms will not work correctly, because the range's save will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure to fwdRange. If func is given the same time point with two different calls, it must return the same result both times.

    Of course, none of the functions in this module have this problem, so it's only relevant if when creating a custom delegate.

    Examples:

        auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
        auto func = (in Date date) //For iterating over even-numbered days.
                    {
                        if((date.day & 1) == 0)
                            return date + dur!"days"(2);

                        return date + dur!"days"(1);
                    };
        auto range = interval.fwdRange(func);

         //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
        assert(range.front == Date(2010, 9, 1));

        range.popFront();
        assert(range.front == Date(2010, 9, 2));

        range.popFront();
        assert(range.front == Date(2010, 9, 4));

        range.popFront();
        assert(range.front == Date(2010, 9, 6));

        range.popFront();
        assert(range.front == Date(2010, 9, 8));

        range.popFront();
        assert(range.empty);

  const IntervalRange!(TP, Direction.bwd) bwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no);
    Returns a range which iterates backwards over the interval, starting at end, using func to generate each successive time point.

    The range's front is the interval's end. func is used to generate the next front when popFront is called. If popFirst is PopFirst.yes, then popFront is called before the range is returned (so that front is a time point which func would generate).

    If func ever generates a time point greater than or equal to the current front of the range, then a DateTimeException will be thrown. The range will be empty and iteration complete when func generates a time point equal to or less than the begin of the interval.

    There are helper functions in this module which generate common delegates to pass to bwdRange. Their documentation starts with "Range-generating function," making them easily searchable.

    Parameters:

    TP delegate(in TP) func | The function used to generate the time points of the range over the interval.
    PopFirst popFirst | Whether popFront should be called on the range before returning it.

    Throws:
    DateTimeException if this interval is empty.

    Warning:
    func must be logically pure. Ideally, func would be a function pointer to a pure function, but forcing func to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass to fwdRange, func must be a delegate.

    If func retains state which changes as it is called, then some algorithms will not work correctly, because the range's save will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure to fwdRange. If func is given the same time point with two different calls, it must return the same result both times.

    Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.

    Examples:

        auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));
        auto func = (in Date date) //For iterating over even-numbered days.
                    {
                        if((date.day & 1) == 0)
                            return date - dur!"days"(2);

                        return date - dur!"days"(1);
                    };
        auto range = interval.bwdRange(func);

        //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).
        assert(range.front == Date(2010, 9, 9));

        range.popFront();
        assert(range.front == Date(2010, 9, 8));

        range.popFront();
        assert(range.front == Date(2010, 9, 6));

        range.popFront();
        assert(range.front == Date(2010, 9, 4));

        range.popFront();
        assert(range.front == Date(2010, 9, 2));

        range.popFront();
        assert(range.empty);

  const nothrow string toString();
    Converts this interval to a string.

struct PosInfInterval(TP);
  Represents an interval of time which has positive infinity as its end point.

  Any ranges which iterate over a PosInfInterval are infinite. So, the main purpose of using PosInfInterval is to create an infinite range which starts at a fixed point in time and goes to positive infinity.

  pure nothrow this(in TP begin);
    Parameters:

    TP begin | The time point which begins the interval.

    Examples:

        auto interval = PosInfInterval!Date(Date(1996, 1, 2));

  pure nothrow PosInfInterval opAssign(ref const PosInfInterval rhs);
    Parameters:

    PosInfInterval rhs | The PosInfInterval to assign to this one.

  pure nothrow PosInfInterval opAssign(PosInfInterval rhs);
    Parameters:

    PosInfInterval rhs | The PosInfInterval to assign to this one.

  const pure nothrow TP begin();
    The starting point of the interval. It is included in the interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).begin == Date(1996, 1, 2));

  pure nothrow void begin(TP timePoint);
    The starting point of the interval. It is included in the interval.

    Parameters:

    TP timePoint | The time point to set begin to.

  const pure nothrow bool empty();
    Whether the interval's length is 0. Always returns false.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).empty);

  const pure nothrow bool contains(TP timePoint);
    Whether the given time point is within this interval.

    Parameters:

    TP timePoint | The time point to check for inclusion in this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(1994, 12, 24)));
        assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(2000, 1, 5)));

  const pure bool contains(in Interval!TP interval);
    Whether the given interval is completely within this interval.

    Parameters:

    Interval!TP interval | The interval to check for inclusion in this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));

  const pure nothrow bool contains(in PosInfInterval interval);
    Whether the given interval is completely within this interval.

    Parameters:

    PosInfInterval interval | The interval to check for inclusion in this interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    PosInfInterval!Date(Date(1995, 7, 2))));

  const pure nothrow bool contains(in NegInfInterval!TP interval);
    Whether the given interval is completely within this interval.

    Always returns false because an interval going to positive infinity can never contain an interval beginning at negative infinity.

    Parameters:

    NegInfInterval!TP interval | The interval to check for inclusion in this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(
                    NegInfInterval!Date(Date(1996, 5, 4))));

  const pure nothrow bool isBefore(in TP timePoint);
    Whether this interval is before the given time point.

    Always returns false because an interval going to positive infinity can never be before any time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is before it.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(1994, 12, 24)));
        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(2000, 1, 5)));

  const pure bool isBefore(in Interval!TP interval);
    Whether this interval is before the given interval and does not intersect it.

    Always returns false (unless the given interval is empty) because an interval going to positive infinity can never be before any other interval.

    Parameters:

    Interval!TP interval | The interval to check for against this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

  const pure nothrow bool isBefore(in PosInfInterval interval);
    Whether this interval is before the given interval and does not intersect it.

    Always returns false because an interval going to positive infinity can never be before any other interval.

    Parameters:

    PosInfInterval interval | The interval to check for against this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
                    PosInfInterval!Date(Date(1992, 5, 4))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
                    PosInfInterval!Date(Date(2013, 3, 7))));

  const pure nothrow bool isBefore(in NegInfInterval!TP interval);
    Whether this interval is before the given interval and does not intersect it.

    Always returns false because an interval going to positive infinity can never be before any other interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check for against this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(
                    NegInfInterval!Date(Date(1996, 5, 4))));

  const pure nothrow bool isAfter(in TP timePoint);
    Whether this interval is after the given time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is after it.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(1994, 12, 24)));
        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(2000, 1, 5)));

  const pure bool isAfter(in Interval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Parameters:

    Interval!TP interval | The interval to check against this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));

  const pure nothrow bool isAfter(in PosInfInterval interval);
    Whether this interval is after the given interval and does not intersect it.

    Always returns false because an interval going to positive infinity can never be after another interval going to positive infinity.

    Parameters:

    PosInfInterval interval | The interval to check against this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    PosInfInterval!Date(Date(1990, 1, 7))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    PosInfInterval!Date(Date(1999, 5, 4))));

  const pure nothrow bool isAfter(in NegInfInterval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Parameters:

    NegInfInterval!TP interval | The interval to check against this interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    NegInfInterval!Date(Date(1996, 1, 2))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(
                    NegInfInterval!Date(Date(2000, 7, 1))));

  const pure bool intersects(in Interval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    Interval!TP interval | The interval to check for intersection with this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));

  const pure nothrow bool intersects(in PosInfInterval interval);
    Whether the given interval overlaps this interval.

    Always returns true because two intervals going to positive infinity always overlap.

    Parameters:

    PosInfInterval interval | The interval to check for intersection with this interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    PosInfInterval!Date(Date(1990, 1, 7))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    PosInfInterval!Date(Date(1999, 5, 4))));

  const pure nothrow bool intersects(in NegInfInterval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check for intersection with this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    NegInfInterval!Date(Date(1996, 1, 2))));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects(
                    NegInfInterval!Date(Date(2000, 7, 1))));

  const Interval!TP intersection(in Interval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    Interval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect or if the given interval is empty.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
               Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));

  const pure nothrow PosInfInterval intersection(in PosInfInterval interval);
    Returns the intersection of two intervals

    Parameters:

    PosInfInterval interval | The interval to intersect with this interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    PosInfInterval!Date(Date(1999, 1, 12))) ==
               PosInfInterval!Date(Date(1999, 1 , 12)));

  const Interval!TP intersection(in NegInfInterval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    NegInfInterval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    NegInfInterval!Date(Date(1999, 7, 6))) ==
               Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               Interval!Date(Date(1996, 1 , 2), Date(2013, 1, 12)));

  const pure bool isAdjacent(in Interval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    Interval!TP interval | The interval to check whether its adjecent to this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
                    Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));

        assert(!PosInfInterval!Date(Date(1999, 1, 12)).isAdjacent(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

  const pure nothrow bool isAdjacent(in PosInfInterval interval);
    Whether the given interval is adjacent to this interval.

    Always returns false because two intervals going to positive infinity can never be adjacent to one another.

    Parameters:

    PosInfInterval interval | The interval to check whether its adjecent to this interval.

    Examples:

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
                    PosInfInterval!Date(Date(1990, 1, 7))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
                    PosInfInterval!Date(Date(1996, 1, 2))));

  const pure nothrow bool isAdjacent(in NegInfInterval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    NegInfInterval!TP interval | The interval to check whether its adjecent to this interval.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
                    NegInfInterval!Date(Date(1996, 1, 2))));

        assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent(
                    NegInfInterval!Date(Date(2000, 7, 1))));

  const PosInfInterval merge(in Interval!TP interval);
    Returns the union of two intervals

    Parameters:

    Interval!TP interval | The interval to merge with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect and are not adjacent or if the given interval is empty.

    Note:
    There is no overload for merge which takes a NegInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  const pure nothrow PosInfInterval merge(in PosInfInterval interval);
    Returns the union of two intervals

    Parameters:

    PosInfInterval interval | The interval to merge with this interval.

    Note:
    There is no overload for merge which takes a NegInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).merge(
                    PosInfInterval!Date(Date(1999, 1, 12))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  const pure PosInfInterval span(in Interval!TP interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    Interval!TP interval | The interval to create a span together with this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Note:
    There is no overload for span which takes a NegInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
                    Interval!Date(Date(500, 8, 9), Date(1602, 1, 31))) ==
               PosInfInterval!Date(Date(500, 8, 9)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  const pure nothrow PosInfInterval span(in PosInfInterval interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    PosInfInterval interval | The interval to create a span together with this interval.

    Note:
    There is no overload for span which takes a NegInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               PosInfInterval!Date(Date(1990, 7 , 6)));

        assert(PosInfInterval!Date(Date(1996, 1, 2)).span(
                    PosInfInterval!Date(Date(1999, 1, 12))) ==
               PosInfInterval!Date(Date(1996, 1 , 2)));

  pure nothrow void shift(D)(D duration) if (__traits(compiles, begin + duration));
    Shifts the begin of this interval forward or backwards in time by the given duration (a positive duration shifts the interval forward; a negative duration shifts it backward). Effectively, it does begin += duration.

    Parameters:

    D duration | The duration to shift the interval by.

    Examples:

        auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
        auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));

        interval1.shift(dur!"days"(50));
        assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));

        interval2.shift(dur!"days"(-50));
        assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));

  void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (isIntegral!T);
    Shifts the begin of this interval forward or backwards in time by the given number of years and/or months (a positive number of years and months shifts the interval forward; a negative number shifts it backward). It adds the years the given years and months to begin. It effectively calls add!"years"() and then add!"months"() on begin with the given number of years and months.

    Parameters:

    T years | The number of years to shift the interval by.
    T months | The number of months to shift the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on begin, causing its month to increment.

    Throws:
    DateTimeException if this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
        auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));

        interval1.shift(dur!"days"(50));
        assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));

        interval2.shift(dur!"days"(-50));
        assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));

  pure nothrow void expand(D)(D duration) if (__traits(compiles, begin + duration));
    Expands the interval backwards in time. Effectively, it does begin -= duration.

    Parameters:

    D duration | The duration to expand the interval by.
    dir | The direction in time to expand the interval.

    Examples:

        auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
        auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));

        interval1.expand(dur!"days"(2));
        assert(interval1 == PosInfInterval!Date(Date(1995, 12, 31)));

        interval2.expand(dur!"days"(-2));
        assert(interval2 == PosInfInterval!Date(Date(1996, 1, 4)));

  void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (isIntegral!T);
    Expands the interval forwards and/or backwards in time. Effectively, it subtracts the given number of months/years from begin.

    Parameters:

    T years | The number of years to expand the interval by.
    T months | The number of months to expand the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on begin, causing its month to increment.

    Throws:
    DateTimeException if this interval is empty or if the resulting interval would be invalid.

    Examples:

        auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));
        auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));

        interval1.expand(2);
        assert(interval1 == PosInfInterval!Date(Date(1994, 1, 2)));

        interval2.expand(-2);
        assert(interval2 == PosInfInterval!Date(Date(1998, 1, 2)));

  const PosInfIntervalRange!TP fwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no);
    Returns a range which iterates forward over the interval, starting at begin, using func to generate each successive time point.

    The range's front is the interval's begin. func is used to generate the next front when popFront is called. If popFirst is PopFirst.yes, then popFront is called before the range is returned (so that front is a time point which func would generate).

    If func ever generates a time point less than or equal to the current front of the range, then a DateTimeException will be thrown.

    There are helper functions in this module which generate common delegates to pass to fwdRange. Their documentation starts with "Range-generating function," to make them easily searchable.

    Parameters:

    TP delegate(in TP) func | The function used to generate the time points of the range over the interval.
    PopFirst popFirst | Whether popFront should be called on the range before returning it.

    Throws:
    DateTimeException if this interval is empty.

    Warning:
    func must be logically pure. Ideally, func would be a function pointer to a pure function, but forcing func to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass to fwdRange, func must be a delegate.

    If func retains state which changes as it is called, then some algorithms will not work correctly, because the range's save will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure to fwdRange. If func is given the same time point with two different calls, it must return the same result both times.

    Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.

    Examples:

        auto interval = PosInfInterval!Date(Date(2010, 9, 1));
        auto func = (in Date date) //For iterating over even-numbered days.
                    {
                        if((date.day & 1) == 0)
                            return date + dur!"days"(2);

                        return date + dur!"days"(1);
                    };
        auto range = interval.fwdRange(func);

        //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).
        assert(range.front == Date(2010, 9, 1));

        range.popFront();
        assert(range.front == Date(2010, 9, 2));

        range.popFront();
        assert(range.front == Date(2010, 9, 4));

        range.popFront();
        assert(range.front == Date(2010, 9, 6));

        range.popFront();
        assert(range.front == Date(2010, 9, 8));

        range.popFront();
        assert(!range.empty);

  const nothrow string toString();
    Converts this interval to a string.

struct NegInfInterval(TP);
  Represents an interval of time which has negative infinity as its starting point.

  Any ranges which iterate over a NegInfInterval are infinite. So, the main purpose of using NegInfInterval is to create an infinite range which starts at negative infinity and goes to a fixed end point. Iterate over it in reverse.

  pure nothrow this(in TP end);
    Parameters:

    begin | The time point which begins the interval.

    Examples:

        auto interval = PosInfInterval!Date(Date(1996, 1, 2));

  pure nothrow NegInfInterval opAssign(ref const NegInfInterval rhs);
    Parameters:

    NegInfInterval rhs | The NegInfInterval to assign to this one.

  pure nothrow NegInfInterval opAssign(NegInfInterval rhs);
    Parameters:

    NegInfInterval rhs | The NegInfInterval to assign to this one.

  const pure nothrow TP end();
    The end point of the interval. It is excluded from the interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).end == Date(2012, 3, 1));

  pure nothrow void end(TP timePoint);
    The end point of the interval. It is excluded from the interval.

    Parameters:

    TP timePoint | The time point to set end to.

  const pure nothrow bool empty();
    Whether the interval's length is 0. Always returns false.

    Examples:

        assert(!NegInfInterval!Date(Date(1996, 1, 2)).empty);

  const pure nothrow bool contains(TP timePoint);
    Whether the given time point is within this interval.

    Parameters:

    TP timePoint | The time point to check for inclusion in this interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(1994, 12, 24)));
        assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2000, 1, 5)));
        assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2012, 3, 1)));

  const pure bool contains(in Interval!TP interval);
    Whether the given interval is completely within this interval.

    Parameters:

    Interval!TP interval | The interval to check for inclusion in this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));

  const pure nothrow bool contains(in PosInfInterval!TP interval);
    Whether the given interval is completely within this interval.

    Always returns false because an interval beginning at negative infinity can never contain an interval going to positive infinity.

    Parameters:

    PosInfInterval!TP interval | The interval to check for inclusion in this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    PosInfInterval!Date(Date(1999, 5, 4))));

  const pure nothrow bool contains(in NegInfInterval interval);
    Whether the given interval is completely within this interval.

    Parameters:

    NegInfInterval interval | The interval to check for inclusion in this interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    NegInfInterval!Date(Date(1996, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(
                    NegInfInterval!Date(Date(2013, 7, 9))));

  const pure nothrow bool isBefore(in TP timePoint);
    Whether this interval is before the given time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is before it.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(1994, 12, 24)));
        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2000, 1, 5)));
        assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2012, 3, 1)));

  const pure bool isBefore(in Interval!TP interval);
    Whether this interval is before the given interval and does not intersect it.

    Parameters:

    Interval!TP interval | The interval to check for against this interval.

    Throws:
    DateTimeException if the given interval is empty

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));

  const pure nothrow bool isBefore(in PosInfInterval!TP interval);
    Whether this interval is before the given interval and does not intersect it.

    Parameters:

    PosInfInterval!TP interval | The interval to check for against this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure nothrow bool isBefore(in NegInfInterval interval);
    Whether this interval is before the given interval and does not intersect it.

    Always returns false because an interval beginning at negative infinity can never be before another interval beginning at negative infinity.

    Parameters:

    NegInfInterval interval | The interval to check for against this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    NegInfInterval!Date(Date(1996, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(
                    NegInfInterval!Date(Date(2013, 7, 9))));

  const pure nothrow bool isAfter(in TP timePoint);
    Whether this interval is after the given time point.

    Always returns false because an interval beginning at negative infinity can never be after any time point.

    Parameters:

    TP timePoint | The time point to check whether this interval is after it.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(1994, 12, 24)));
        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2000, 1, 5)));
        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2012, 3, 1)));

  const pure bool isAfter(in Interval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Always returns false (unless the given interval is empty) because an interval beginning at negative infinity can never be after any other interval.

    Parameters:

    Interval!TP interval | The interval to check against this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));

  const pure nothrow bool isAfter(in PosInfInterval!TP interval);
    Whether this interval is after the given interval and does not intersect it.

    Always returns false because an interval beginning at negative infinity can never be after any other interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check against this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure nothrow bool isAfter(in NegInfInterval interval);
    Whether this interval is after the given interval and does not intersect it.

    Always returns false because an interval beginning at negative infinity can never be after any other interval.

    Parameters:

    NegInfInterval interval | The interval to check against this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    NegInfInterval!Date(Date(1996, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(
                    NegInfInterval!Date(Date(2013, 7, 9))));

  const pure bool intersects(in Interval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    Interval!TP interval | The interval to check for intersection with this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));

  const pure nothrow bool intersects(in PosInfInterval!TP interval);
    Whether the given interval overlaps this interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check for intersection with this interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure nothrow bool intersects(in NegInfInterval!TP interval);
    Whether the given interval overlaps this interval.

    Always returns true because two intervals beginning at negative infinity always overlap.

    Parameters:

    NegInfInterval!TP interval | The interval to check for intersection with this interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    NegInfInterval!Date(Date(1996, 5, 4))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects(
                    NegInfInterval!Date(Date(2013, 7, 9))));

  const Interval!TP intersection(in Interval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    Interval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect or if the given interval is empty.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               Interval!Date(Date(1990, 7 , 6), Date(2000, 8, 2)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
               Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));

  const Interval!TP intersection(in PosInfInterval!TP interval);
    Returns the intersection of two intervals

    Parameters:

    PosInfInterval!TP interval | The interval to intersect with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    PosInfInterval!Date(Date(1990, 7, 6))) ==
               Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    PosInfInterval!Date(Date(1999, 1, 12))) ==
               Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));

  const nothrow NegInfInterval intersection(in NegInfInterval interval);
    Returns the intersection of two intervals

    Parameters:

    NegInfInterval interval | The interval to intersect with this interval.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    NegInfInterval!Date(Date(1999, 7, 6))) ==
               NegInfInterval!Date(Date(1999, 7 , 6)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

  const pure bool isAdjacent(in Interval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    Interval!TP interval | The interval to check whether its adjecent to this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(1999, 1, 12), Date(2012, 3, 1))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(2012, 3, 1), Date(2019, 2, 2))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));

  const pure nothrow bool isAdjacent(in PosInfInterval!TP interval);
    Whether the given interval is adjacent to this interval.

    Parameters:

    PosInfInterval!TP interval | The interval to check whether its adjecent to this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    PosInfInterval!Date(Date(1999, 5, 4))));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    PosInfInterval!Date(Date(2012, 3, 1))));

  const pure nothrow bool isAdjacent(in NegInfInterval interval);
    Whether the given interval is adjacent to this interval.

    Always returns false because two intervals beginning at negative infinity can never be adjacent to one another.

    Parameters:

    NegInfInterval interval | The interval to check whether its adjecent to this interval.

    Examples:

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    NegInfInterval!Date(Date(1996, 5, 4))));

        assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent(
                    NegInfInterval!Date(Date(2012, 3, 1))));

  const NegInfInterval merge(in Interval!TP interval);
    Returns the union of two intervals

    Parameters:

    Interval!TP interval | The interval to merge with this interval.

    Throws:
    DateTimeException if the two intervals do not intersect and are not adjacent or if the given interval is empty.

    Note:
    There is no overload for merge which takes a PosInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
                    Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
               NegInfInterval!Date(Date(2015, 9 , 2)));

  const pure nothrow NegInfInterval merge(in NegInfInterval interval);
    Returns the union of two intervals

    Parameters:

    NegInfInterval interval | The interval to merge with this interval.

    Note:
    There is no overload for merge which takes a PosInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
                    NegInfInterval!Date(Date(1999, 7, 6))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).merge(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               NegInfInterval!Date(Date(2013, 1 , 12)));

  const pure NegInfInterval span(in Interval!TP interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    Interval!TP interval | The interval to create a span together with this interval.

    Throws:
    DateTimeException if the given interval is empty.

    Note:
    There is no overload for span which takes a PosInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
                    Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
                    Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) ==
               NegInfInterval!Date(Date(2015, 9 , 2)));

        assert(NegInfInterval!Date(Date(1600, 1, 7)).span(
                    Interval!Date(Date(2012, 3, 11), Date(2017, 7, 1))) ==
               NegInfInterval!Date(Date(2017, 7 , 1)));

  const pure nothrow NegInfInterval span(in NegInfInterval interval);
    Returns an interval that covers from the earliest time point of two intervals up to (but not including) the latest time point of two intervals.

    Parameters:

    NegInfInterval interval | The interval to create a span together with this interval.

    Note:
    There is no overload for span which takes a PosInfInterval, because an interval going from negative infinity to positive infinity is not possible.

    Examples:

        assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
                    NegInfInterval!Date(Date(1999, 7, 6))) ==
               NegInfInterval!Date(Date(2012, 3 , 1)));

        assert(NegInfInterval!Date(Date(2012, 3, 1)).span(
                    NegInfInterval!Date(Date(2013, 1, 12))) ==
               NegInfInterval!Date(Date(2013, 1 , 12)));

  pure nothrow void shift(D)(D duration) if (__traits(compiles, end + duration));
    Shifts the end of this interval forward or backwards in time by the given duration (a positive duration shifts the interval forward; a negative duration shifts it backward). Effectively, it does end += duration.

    Parameters:

    D duration | The duration to shift the interval by.

    Examples:

        auto interval1 = NegInfInterval!Date(Date(2012, 4, 5));
        auto interval2 = NegInfInterval!Date(Date(2012, 4, 5));

        interval1.shift(dur!"days"(50));
        assert(interval1 == NegInfInterval!Date(Date(2012, 5, 25)));

        interval2.shift(dur!"days"(-50));
        assert(interval2 == NegInfInterval!Date( Date(2012, 2, 15)));

  void shift(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (isIntegral!T);
    Shifts the end of this interval forward or backwards in time by the given number of years and/or months (a positive number of years and months shifts the interval forward; a negative number shifts it backward). It adds the years the given years and months to end. It effectively calls add!"years"() and then add!"months"() on end with the given number of years and months.

    Parameters:

    T years | The number of years to shift the interval by.
    T months | The number of months to shift the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on end, causing its month to increment.

    Throws:
    DateTimeException if empty is true or if the resulting interval would be invalid.

    Examples:

        auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
        auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));

        interval1.shift(2);
        assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));

        interval2.shift(-2);
        assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));

  pure nothrow void expand(D)(D duration) if (__traits(compiles, end + duration));
    Expands the interval forwards in time. Effectively, it does end += duration.

    Parameters:

    D duration | The duration to expand the interval by.
    dir | The direction in time to expand the interval.

    Examples:

        auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
        auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));

        interval1.expand(dur!"days"(2));
        assert(interval1 == NegInfInterval!Date(Date(2012, 3, 3)));

        interval2.expand(dur!"days"(-2));
        assert(interval2 == NegInfInterval!Date(Date(2012, 2, 28)));

  void expand(T)(T years, T months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (isIntegral!T);
    Expands the interval forwards and/or backwards in time. Effectively, it adds the given number of months/years to end.

    Parameters:

    T years | The number of years to expand the interval by.
    T months | The number of months to expand the interval by.
    AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on end, causing their month to increment.

    Throws:
    DateTimeException if empty is true or if the resulting interval would be invalid.

    Examples:

        auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));
        auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));

        interval1.expand(2);
        assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));

        interval2.expand(-2);
        assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));

  const NegInfIntervalRange!TP bwdRange(TP delegate(in TP) func, PopFirst popFirst = PopFirst.no);
    Returns a range which iterates backwards over the interval, starting at end, using func to generate each successive time point.

    The range's front is the interval's end. func is used to generate the next front when popFront is called. If popFirst is PopFirst.yes, then popFront is called before the range is returned (so that front is a time point which func would generate).

    If func ever generates a time point greater than or equal to the current front of the range, then a DateTimeException will be thrown.

    There are helper functions in this module which generate common delegates to pass to bwdRange. Their documentation starts with "Range-generating function," to make them easily searchable.

    Parameters:

    TP delegate(in TP) func | The function used to generate the time points of the range over the interval.
    PopFirst popFirst | Whether popFront should be called on the range before returning it.

    Throws:
    DateTimeException if this interval is empty.

    Warning:
    func must be logically pure. Ideally, func would be a function pointer to a pure function, but forcing func to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass to fwdRange, func must be a delegate.

    If func retains state which changes as it is called, then some algorithms will not work correctly, because the range's save will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure to fwdRange. If func is given the same time point with two different calls, it must return the same result both times.

    Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.

    Examples:

        auto interval = NegInfInterval!Date(Date(2010, 9, 9));
        auto func = (in Date date) //For iterating over even-numbered days.
                    {
                        if((date.day & 1) == 0)
                            return date - dur!"days"(2);

                        return date - dur!"days"(1);
                    };
        auto range = interval.bwdRange(func);

        assert(range.front == Date(2010, 9, 9)); //An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).

        range.popFront();
        assert(range.front == Date(2010, 9, 8));

        range.popFront();
        assert(range.front == Date(2010, 9, 6));

        range.popFront();
        assert(range.front == Date(2010, 9, 4));

        range.popFront();
        assert(range.front == Date(2010, 9, 2));

        range.popFront();
        assert(!range.empty);

  const nothrow string toString();
    Converts this interval to a string.

nothrow TP delegate(in TP) everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayOfWeek dayOfWeek) if (isTimePoint!TP && (dir == Direction.fwd || dir == Direction.bwd) && __traits(hasMember, TP, "dayOfWeek") && !__traits(isStaticFunction, TP.dayOfWeek) && is(typeof(TP.dayOfWeek) == DayOfWeek));
  Range-generating function.

  Returns a delegate which returns the next time point with the given DayOfWeek in a range.

  Using this delegate allows iteration over successive time points which are all the same day of the week. e.g. passing DayOfWeek.mon to everyDayOfWeek would result in a delegate which could be used to iterate over all of the Mondays in a range.

  Parameters:

  dir | The direction to iterate in. If passing the return value to fwdRange, use Direction.fwd. If passing it to bwdRange, use Direction.bwd.
  DayOfWeek dayOfWeek | The week that each time point in the range will be.

  Examples:

      auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
      auto func = everyDayOfWeek!Date(DayOfWeek.mon);
      auto range = interval.fwdRange(func);

      //A Thursday. Using PopFirst.yes would have made this Date(2010, 9, 6).
      assert(range.front == Date(2010, 9, 2));

      range.popFront();
      assert(range.front == Date(2010, 9, 6));

      range.popFront();
      assert(range.front == Date(2010, 9, 13));

      range.popFront();
      assert(range.front == Date(2010, 9, 20));

      range.popFront();
      assert(range.empty);

TP delegate(in TP) everyMonth(TP, Direction dir = Direction.fwd)(int month) if (isTimePoint!TP && (dir == Direction.fwd || dir == Direction.bwd) && __traits(hasMember, TP, "month") && !__traits(isStaticFunction, TP.month) && is(typeof(TP.month) == Month));
  Range-generating function.

  Returns a delegate which returns the next time point with the given month which would be reached by adding months to the given time point.

  So, using this delegate allows iteration over successive time points which are in the same month but different years. For example, iterate over each successive December 25th in an interval by starting with a date which had the 25th as its day and passed Month.dec to everyMonth to create the delegate.

  Since it wouldn't really make sense to be iterating over a specific month and end up with some of the time points in the succeeding month or two years after the previous time point, AllowDayOverflow.no is always used when calculating the next time point.

  Parameters:

  dir | The direction to iterate in. If passing the return value to fwdRange, use Direction.fwd. If passing it to bwdRange, use Direction.bwd.
  int month | The month that each time point in the range will be in.

  Examples:

      auto interval = Interval!Date(Date(2000, 1, 30), Date(2004, 8, 5));
      auto func = everyMonth!(Date)(Month.feb);
      auto range = interval.fwdRange(func);

      //Using PopFirst.yes would have made this Date(2010, 2, 29).
      assert(range.front == Date(2000, 1, 30));

      range.popFront();
      assert(range.front == Date(2000, 2, 29));

      range.popFront();
      assert(range.front == Date(2001, 2, 28));

      range.popFront();
      assert(range.front == Date(2002, 2, 28));

      range.popFront();
      assert(range.front == Date(2003, 2, 28));

      range.popFront();
      assert(range.front == Date(2004, 2, 28));

      range.popFront();
      assert(range.empty);

nothrow TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D)(D duration) if (isTimePoint!TP && __traits(compiles, TP.init + duration) && (dir == Direction.fwd || dir == Direction.bwd));
  Range-generating function.

  Returns a delegate which returns the next time point which is the given duration later.

  Using this delegate allows iteration over successive time points which are apart by the given duration e.g. passing dur!"days"(3) to everyDuration would result in a delegate which could be used to iterate over a range of days which are each 3 days apart.

  Parameters:

  dir | The direction to iterate in. If passing the return value to fwdRange, use Direction.fwd. If passing it to bwdRange, use Direction.bwd.
  D duration | The duration which separates each successive time point in the range.

  Examples:

      auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
      auto func = everyDuration!Date(dur!"days"(8));
      auto range = interval.fwdRange(func);

      //Using PopFirst.yes would have made this Date(2010, 9, 10).
      assert(range.front == Date(2010, 9, 2));

      range.popFront();
      assert(range.front == Date(2010, 9, 10));

      range.popFront();
      assert(range.front == Date(2010, 9, 18));

      range.popFront();
      assert(range.front == Date(2010, 9, 26));

      range.popFront();
      assert(range.empty);

nothrow TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D)(int years, int months = 0, AllowDayOverflow allowOverflow = AllowDayOverflow.yes, D duration = dur!"days"(0)) if (isTimePoint!TP && __traits(compiles, TP.init + duration) && __traits(compiles, TP.init.add!"years"(years)) && __traits(compiles, TP.init.add!"months"(months)) && (dir == Direction.fwd || dir == Direction.bwd));
  Range-generating function.

  Returns a delegate which returns the next time point which is the given number of years, month, and duration later.

  The difference between this version of everyDuration and the version which just takes a Duration is that this one also takes the number of years and months (along with an AllowDayOverflow to indicate whether adding years and months should allow the days to overflow).

  Note that if iterating forward, add!"years"() is called on the given time point, then add!"months"(), and finally the duration is added to it. However, if iterating backwards, the duration is added first, then add!"months"() is called, and finally add!"years"() is called. That way, going backwards generates close to the same time points that iterating forward does, but since adding years and months is not entirely reversible (due to possible day overflow, regardless of whether AllowDayOverflow.yes or AllowDayOverflow.no is used), it can't be guaranteed that iterating backwards will give the same time points as iterating forward would have (even assuming that the end of the range is a time point which would be returned by the delegate when iterating forward from begin).

  Parameters:

  dir | The direction to iterate in. If passing the return value to fwdRange, use Direction.fwd. If passing it to bwdRange, use Direction.bwd.
  int years | The number of years to add to the time point passed to the delegate.
  int months | The number of months to add to the time point passed to the delegate.
  AllowDayOverflow allowOverflow | Whether the days should be allowed to overflow on begin and end, causing their month to increment.
  D duration | The duration to add to the time point passed to the delegate.

  Examples:

      auto interval = Interval!Date(Date(2010, 9, 2), Date(2025, 9, 27));
      auto func = everyDuration!Date(4, 1, AllowDayOverflow.yes, dur!"days"(2));
      auto range = interval.fwdRange(func);

      //Using PopFirst.yes would have made this Date(2014, 10, 12).
      assert(range.front == Date(2010, 9, 2));

      range.popFront();
      assert(range.front == Date(2014, 10, 4));

      range.popFront();
      assert(range.front == Date(2018, 11, 6));

      range.popFront();
      assert(range.front == Date(2022, 12, 8));

      range.popFront();
      assert(range.empty);

struct IntervalRange(TP, Direction dir) if (isTimePoint!TP && dir != Direction.both);
  A range over an Interval.

  IntervalRange is only ever constructed by Interval. However, when it is constructed, it is given a function, func, which is used to generate the time points which are iterated over. func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the interval Interval!Date, pass a function to Interval's fwdRange where that function took a Date and returned a Date which was one day later. That function would then be used by IntervalRange's popFront to iterate over the Dates in the interval.

  If dir == Direction.fwd, then a range iterates forward in time, whereas if dir == Direction.bwd, then it iterates backwards in time. So, if dir == Direction.fwd then front == interval.begin, whereas if dir == Direction.bwd then front == interval.end. func must generate a time point going in the proper direction of iteration, or a DateTimeException will be thrown. So, to iterate forward in time, the time point that func generates must be later in time than the one passed to it. If it's either identical or earlier in time, then a DateTimeException will be thrown. To iterate backwards, then the generated time point must be before the time point which was passed in.

  If the generated time point is ever passed the edge of the range in the proper direction, then the edge of that range will be used instead. So, if iterating forward, and the generated time point is past the interval's end, then front becomes end. If iterating backwards, and the generated time point is before begin, then front becomes begin. In either case, the range would then be empty.

  Also note that while normally the begin of an interval is included in it and its end is excluded from it, if dir == Direction.bwd, then begin is treated as excluded and end is treated as included. This allows for the same behavior in both directions. This works because none of Interval's functions which care about whether begin or end is included or excluded are ever called by IntervalRange. interval returns a normal interval, regardless of whether dir == Direction.fwd or if dir == Direction.bwd, so any Interval functions which are called on it which care about whether begin or end are included or excluded will treat begin as included and end as excluded.

  pure nothrow IntervalRange opAssign(ref IntervalRange rhs);
    Parameters:

    IntervalRange rhs | The IntervalRange to assign to this one.

  const pure nothrow bool empty();
    Whether this IntervalRange is empty.

  const pure TP front();
    The first time point in the range.

    Throws:
    DateTimeException if the range is empty.

  void popFront();
    Pops front from the range, using func to generate the next time point in the range. If the generated time point is beyond the edge of the range, then front is set to that edge, and the range is then empty. So, if iterating forwards, and the generated time point is greater than the interval's end, then front is set to end. If iterating backwards, and the generated time point is less than the interval's begin, then front is set to begin.

    Throws:
    DateTimeException if the range is empty or if the generated time point is in the wrong direction (i.e. if iterating forward and the generated time point is before front, or if iterating backwards and the generated time point is after front).

  pure nothrow IntervalRange save();
    Returns a copy of this.

  const pure nothrow Interval!TP interval();
    The interval that this IntervalRange currently covers.

  pure nothrow @property TP delegate(in TP) func();
    The function used to generate the next time point in the range.

  const pure nothrow Direction direction();
    The Direction that this range iterates in.

struct PosInfIntervalRange(TP) if (isTimePoint!TP);
  A range over a PosInfInterval. It is an infinite range.

  PosInfIntervalRange is only ever constructed by PosInfInterval. However, when it is constructed, it is given a function, func, which is used to generate the time points which are iterated over. func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the interval PosInfInterval!Date, pass a function to PosInfInterval's fwdRange where that function took a Date and returned a Date which was one day later. That function would then be used by PosInfIntervalRange's popFront to iterate over the Dates in the interval - though obviously, since the range is infinite, use a function such as std.range.take with it rather than iterating over all of the dates.

  As the interval goes to positive infinity, the range is always iterated over forwards, never backwards. func must generate a time point going in the proper direction of iteration, or a DateTimeException will be thrown. So, the time points that func generates must be later in time than the one passed to it. If it's either identical or earlier in time, then a DateTimeException will be thrown.

  pure nothrow PosInfIntervalRange opAssign(ref PosInfIntervalRange rhs);
    Parameters:

    PosInfIntervalRange rhs | The PosInfIntervalRange to assign to this one.

  bool empty;
    This is an infinite range, so it is never empty.

  const pure nothrow TP front();
    The first time point in the range.

  void popFront();
    Pops front from the range, using func to generate the next time point in the range.

    Throws:
    DateTimeException if the generated time point is less than front.

  pure nothrow PosInfIntervalRange save();
    Returns a copy of this.

  const pure nothrow PosInfInterval!TP interval();
    The interval that this range currently covers.

  pure nothrow @property TP delegate(in TP) func();
    The function used to generate the next time point in the range.

struct NegInfIntervalRange(TP) if (isTimePoint!TP);
  A range over a NegInfInterval. It is an infinite range.

  NegInfIntervalRange is only ever constructed by NegInfInterval. However, when it is constructed, it is given a function, func, which is used to generate the time points which are iterated over. func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the interval NegInfInterval!Date, pass a function to NegInfInterval's bwdRange where that function took a Date and returned a Date which was one day earlier. That function would then be used by NegInfIntervalRange's popFront to iterate over the Dates in the interval - though obviously, since the range is infinite, use a function such as std.range.take with it rather than iterating over all of the dates.

  As the interval goes to negative infinity, the range is always iterated over backwards, never forwards. func must generate a time point going in the proper direction of iteration, or a DateTimeException will be thrown. So, the time points that func generates must be earlier in time than the one passed to it. If it's either identical or later in time, then a DateTimeException will be thrown.

  Also note that while normally the end of an interval is excluded from it, NegInfIntervalRange treats it as if it were included. This allows for the same behavior as with PosInfIntervalRange. This works because none of NegInfInterval's functions which care about whether end is included or excluded are ever called by NegInfIntervalRange. interval returns a normal interval, so any NegInfInterval functions which are called on it which care about whether end is included or excluded will treat end as excluded.

  pure nothrow NegInfIntervalRange opAssign(ref NegInfIntervalRange rhs);
    Parameters:

    NegInfIntervalRange rhs | The NegInfIntervalRange to assign to this one.

  bool empty;
    This is an infinite range, so it is never empty.

  const pure nothrow TP front();
    The first time point in the range.

  void popFront();
    Pops front from the range, using func to generate the next time point in the range.

    Throws:
    DateTimeException if the generated time point is greater than front.

  pure nothrow NegInfIntervalRange save();
    Returns a copy of this.

  const pure nothrow NegInfInterval!TP interval();
    The interval that this range currently covers.

  pure nothrow @property TP delegate(in TP) func();
    The function used to generate the next time point in the range.

abstract class TimeZone;
  Represents a time zone. It is used with SysTime to indicate the time zone of a SysTime.

  const nothrow @property string name();
    The name of the time zone per the TZ Database. This is the name used to get a TimeZone by name with TimeZone.getTimeZone.

    See Also:
    Wikipedia entry on TZ Database
    List of Time Zones

  const nothrow @property string stdName();
    Typically, the abbreviation (generally 3 or 4 letters) for the time zone when DST is not in effect (e.g. PST). It is not necessarily unique.

    However, on Windows, it may be the unabbreviated name (e.g. Pacific Standard Time). Regardless, it is not the same as name.

  const nothrow @property string dstName();
    Typically, the abbreviation (generally 3 or 4 letters) for the time zone when DST is in effect (e.g. PDT). It is not necessarily unique.

    However, on Windows, it may be the unabbreviated name (e.g. Pacific Daylight Time). Regardless, it is not the same as name.

  abstract const nothrow @property bool hasDST();
    Whether this time zone has Daylight Savings Time at any point in time. Note that for some time zone types it may not have DST for current dates but will still return true for hasDST because the time zone did at some point have DST.

  abstract const nothrow bool dstInEffect(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and returns whether DST is effect in this time zone at the given point in time.

    Parameters:

    long stdTime | The UTC time that needs to be checked for DST in this time zone.

  abstract const nothrow long utcToTZ(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and converts it to this time zone's time.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

  abstract const nothrow long tzToUTC(long adjTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in this time zone's time and converts it to UTC (i.e. std time).

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

  const nothrow Duration utcOffsetAt(long stdTime);
    Returns what the offset from UTC is at the given std time. It includes the DST offset in effect at that time (if any).

    Parameters:

    long stdTime | The UTC time for which to get the offset from UTC for this time zone.

  static immutable(TimeZone) getTimeZone(string name);
    Returns a TimeZone with the give name per the TZ Database.

    This returns a PosixTimeZone on Posix systems and a WindowsTimeZone on Windows systems. For PosixTimeZone on Windows, call PosixTimeZone.getTimeZone directly and give it the location of the TZ Database time zone files on disk.

    On Windows, the given TZ Database name is converted to the corresponding time zone name on Windows prior to calling WindowsTimeZone.getTimeZone. This function allows for the same time zone names on both Windows and Posix systems.

    See Also:
    Wikipedia entry on TZ Database
    List of Time Zones
    Windows <-> TZ Database Name Conversion Table

    Parameters:

    string name | The TZ Database name of the desired time zone

    Throws:
    DateTimeException if the given time zone could not be found.

    Examples:

        auto tz = TimeZone.getTimeZone("America/Los_Angeles");

  static string[] getInstalledTZNames(string subName = "");
    Returns a list of the names of the time zones installed on the system.

    Providing a sub-name narrows down the list of time zones (which can number in the thousands). For example, passing in "America" as the sub-name returns only the time zones which begin with "America".

    On Windows, this function will convert the Windows time zone names to the corresponding TZ Database names with windowsTZNameToTZDatabaseName. To get the actual Windows time zone names, use WindowsTimeZone.getInstalledTZNames directly.

    Parameters:

    string subName | The first part of the time zones desired.

    Throws:
    FileException on Posix systems if it fails to read from disk. DateTimeException on Windows systems if it fails to read the registry.

class LocalTime: std.datetime.TimeZone;
  A TimeZone which represents the current local time zone on the system running your program.

  This uses the underlying C calls to adjust the time rather than using specific D code based off of system settings to calculate the time such as PosixTimeZone and WindowsTimeZone do. That also means that it will use whatever the current time zone is on the system, even if the system's time zone changes while the program is running.

  static pure nothrow immutable(LocalTime) opCall();
    LocalTime is a singleton class. LocalTime returns its only instance.

  const nothrow @property string name();
    The name of the time zone per the TZ Database. This is the name used to get a TimeZone by name with TimeZone.getTimeZone.

    Note that this always returns the empty string. This is because time zones cannot be uniquely identified by the attributes given by the OS (such as the stdName and dstName), and neither Posix systems nor Windows systems provide an easy way to get the TZ Database name of the local time zone.

    See Also:
    Wikipedia entry on TZ Database
    List of Time Zones

  const nothrow @property string stdName();
    Typically, the abbreviation (generally 3 or 4 letters) for the time zone when DST is not in effect (e.g. PST). It is not necessarily unique.

    However, on Windows, it may be the unabbreviated name (e.g. Pacific Standard Time). Regardless, it is not the same as name.

    This property is overridden because the local time of the system could change while the program is running and we need to determine it dynamically rather than it being fixed like it would be with most time zones.

  const nothrow @property string dstName();
    Typically, the abbreviation (generally 3 or 4 letters) for the time zone when DST is in effect (e.g. PDT). It is not necessarily unique.

    However, on Windows, it may be the unabbreviated name (e.g. Pacific Daylight Time). Regardless, it is not the same as name.

    This property is overridden because the local time of the system could change while the program is running and we need to determine it dynamically rather than it being fixed like it would be with most time zones.

  const nothrow @property bool hasDST();
    Whether this time zone has Daylight Savings Time at any point in time. Note that for some time zone types it may not have DST for current dates but will still return true for hasDST because the time zone did at some point have DST.

  const nothrow bool dstInEffect(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and returns whether DST is in effect in this time zone at the given point in time.

    Parameters:

    long stdTime | The UTC time that needs to be checked for DST in this time zone.

  const nothrow long utcToTZ(long stdTime);
    Returns hnsecs in the local time zone using the standard C function calls on Posix systems and the standard Windows system calls on Windows systems to adjust the time to the appropriate time zone from std time.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

    See Also:
    TimeZone.utcToTZ

  const nothrow long tzToUTC(long adjTime);
    Returns std time using the standard C function calls on Posix systems and the standard Windows system calls on Windows systems to adjust the time to UTC from the appropriate time zone.

    See Also:
    TimeZone.tzToUTC

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

class UTC: std.datetime.TimeZone;
  A TimeZone which represents UTC.

  static pure nothrow immutable(UTC) opCall();
    UTC is a singleton class. UTC returns its only instance.

  const nothrow @property bool hasDST();
    Always returns false.

  const nothrow bool dstInEffect(long stdTime);
    Always returns false.

  const nothrow long utcToTZ(long stdTime);
    Returns the given hnsecs without changing them at all.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

    See Also:
    TimeZone.utcToTZ

  const nothrow long tzToUTC(long adjTime);
    Returns the given hnsecs without changing them at all.

    See Also:
    TimeZone.tzToUTC

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

  const nothrow Duration utcOffsetAt(long stdTime);
    Returns a core.time.Duration of 0.

    Parameters:

    long stdTime | The UTC time for which to get the offset from UTC for this time zone.

class SimpleTimeZone: std.datetime.TimeZone;
  Represents a time zone with an offset (in minutes, west is negative) from UTC but no DST.

  It's primarily used as the time zone in the result of SysTime's fromISOString, fromISOExtString, and fromSimpleString.

  name and dstName are always the empty string since this time zone has no DST, and while it may be meant to represent a time zone which is in the TZ Database, obviously it's not likely to be following the exact rules of any of the time zones in the TZ Database, so it makes no sense to set it.

  const nothrow @property bool hasDST();
    Always returns false.

  const nothrow bool dstInEffect(long stdTime);
    Always returns false.

  const nothrow long utcToTZ(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and converts it to this time zone's time.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

  const nothrow long tzToUTC(long adjTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in this time zone's time and converts it to UTC (i.e. std time).

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

  const nothrow Duration utcOffsetAt(long stdTime);
    Returns utcOffset as a core.time.Duration.

    Parameters:

    long stdTime | The UTC time for which to get the offset from UTC for this time zone.

  immutable this(Duration utcOffset, string stdName = "");
  immutable this(int utcOffset, string stdName = "");
    Parameters:

    Duration utcOffset | This time zone's offset from UTC in minutes with west of UTC being negative (it is added to UTC to get the adjusted time).
    string stdName | The stdName for this time zone.

  const pure nothrow @property @safe int utcOffset();
    The number of minutes the offset from UTC is (negative is west of UTC, positive is east).

class PosixTimeZone: std.datetime.TimeZone;
  Represents a time zone from a TZ Database time zone file. Files from the TZ Database are how Posix systems hold their time zone information. Unfortunately, Windows does not use the TZ Database. To use the TZ Database, use PosixTimeZone">PosixTimeZone (which reads its information from the TZ Database files on disk) on Windows by providing the TZ Database files and telling PosixTimeZone.getTimeZone where the directory holding them is.

  To get a PosixTimeZone, either call PosixTimeZone.getTimeZone (which allows specifying the location the time zone files) or call TimeZone.getTimeZone (which will give a PosixTimeZone on Posix systems and a WindowsTimeZone on Windows systems).

  Note:
  Unless your system's local time zone deals with leap seconds (which is highly unlikely), then the only way to get a time zone which takes leap seconds into account is to use PosixTimeZone with a time zone whose name starts with "right/". Those time zone files do include leap seconds, and PosixTimeZone will take them into account (though posix systems which use a "right/" time zone as their local time zone will not take leap seconds into account even though they're in the file).

  See Also:
  Home of the TZ Database files
  Wikipedia entry on TZ Database
  List of Time Zones

  const nothrow @property bool hasDST();
    Whether this time zone has Daylight Savings Time at any point in time. Note that for some time zone types it may not have DST for current dates but will still return true for hasDST because the time zone did at some point have DST.

  const nothrow bool dstInEffect(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and returns whether DST is in effect in this time zone at the given point in time.

    Parameters:

    long stdTime | The UTC time that needs to be checked for DST in this time zone.

  const nothrow long utcToTZ(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and converts it to this time zone's time.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

  const nothrow long tzToUTC(long adjTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in this time zone's time and converts it to UTC (i.e. std time).

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

  string defaultTZDatabaseDir;
    The default directory where the TZ Database files are. It's empty for Windows, since Windows doesn't have them.

  static immutable(PosixTimeZone) getTimeZone(string name, string tzDatabaseDir = defaultTZDatabaseDir);
    Returns a TimeZone with the give name per the TZ Database. The time zone information is fetched from the TZ Database time zone files in the given directory.

    See Also:
    Wikipedia entry on TZ Database
    List of Time Zones

    Parameters:

    string name | The TZ Database name of the desired time zone
    string tzDatabaseDir | The directory where the TZ Database files are located. Because these files are not located on Windows systems, provide them and give their location here to use PosixTimeZones.

    Throws:
    DateTimeException if the given time zone could not be found or FileException if the TZ Database file could not be opened.

    Examples:

        auto tz = PosixTimeZone.getTimeZone("America/Los_Angeles");

        assert(tz.name == "America/Los_Angeles");
        assert(tz.stdName == "PST");
        assert(tz.dstName == "PDT");

  static string[] getInstalledTZNames(string subName = "", string tzDatabaseDir = defaultTZDatabaseDir);
    Returns a list of the names of the time zones installed on the system.

    Providing a sub-name narrows down the list of time zones (which can number in the thousands). For example, passing in "America" as the sub-name returns only the time zones which begin with "America".

    Parameters:

    string subName | The first part of the desired time zones.

    Throws:
    FileException if it fails to read from disk.

class WindowsTimeZone: std.datetime.TimeZone;
  This class is Windows-Only.

  Represents a time zone from the Windows registry. Unfortunately, Windows does not use the TZ Database. To use the TZ Database, use PosixTimeZone (which reads its information from the TZ Database files on disk) on Windows by providing the TZ Database files and telling PosixTimeZone.getTimeZone where the directory holding them is.

  The TZ Database files and Windows' time zone information frequently do not match. Windows has many errors with regards to when DST switches occur (especially for historical dates). Also, the TZ Database files include far more time zones than Windows does. So, for accurate time zone information, use the TZ Database files with PosixTimeZone rather than WindowsTimeZone. However, because WindowsTimeZone uses Windows system calls to deal with the time, it's far more likely to match the behavior of other Windows programs. Be aware of the differences when selecting a method.

  WindowsTimeZone does not exist on Posix systems.

  To get a WindowsTimeZone, either call WindowsTimeZone.getTimeZone or call TimeZone.getTimeZone (which will give a PosixTimeZone on Posix systems and a WindowsTimeZone on Windows systems).

  See Also:
  Home of the TZ Database files

  const nothrow @property bool hasDST();
    Whether this time zone has Daylight Savings Time at any point in time. Note that for some time zone types it may not have DST for current dates but will still return true for hasDST because the time zone did at some point have DST.

  const nothrow bool dstInEffect(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and returns whether DST is in effect in this time zone at the given point in time.

    Parameters:

    long stdTime | The UTC time that needs to be checked for DST in this time zone.

  const nothrow long utcToTZ(long stdTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in UTC time (i.e. std time) and converts it to this time zone's time.

    Parameters:

    long stdTime | The UTC time that needs to be adjusted to this time zone's time.

  const nothrow long tzToUTC(long adjTime);
    Takes the number of hnsecs (100 ns) since midnight, January 1st, 1 A.D. in this time zone's time and converts it to UTC (i.e. std time).

    Parameters:

    long adjTime | The time in this time zone that needs to be adjusted to UTC time.

  static immutable(WindowsTimeZone) getTimeZone(string name);
    Returns a TimeZone with the given name per the Windows time zone names. The time zone information is fetched from the Windows registry.

    See Also:
    Wikipedia entry on TZ Database
    List of Time Zones

    Parameters:

    string name | The TZ Database name of the desired time zone.

    Throws:
    DateTimeException if the given time zone could not be found.

    Examples:

        auto tz = TimeZone.getTimeZone("America/Los_Angeles");

  static string[] getInstalledTZNames();
    Returns a list of the names of the time zones installed on the system.

void setTZEnvVar(string tzDatabaseName);
  This function is Posix-Only.

  Sets the local time zone on Posix systems with the TZ Database name by setting the TZ environment variable.

  Unfortunately, there is no way to do it on Windows using the TZ Database name, so this function only exists on Posix systems.

void clearTZEnvVar();
  This function is Posix-Only.

  Clears the TZ environment variable.

string tzDatabaseNameToWindowsTZName(string tzName);
  Converts the given TZ Database name to the corresponding Windows time zone name.

  Note that in a few cases, a TZ Dabatase name corresponds to two different Windows time zone names. So, while in most cases converting from one to the other and back again will result in the same time zone name started with, in a few case, it'll get a different name.

  Also, there are far more TZ Database names than Windows time zones, so some of the more exotic TZ Database names don't have corresponding Windows time zone names.

  See Also:
  Windows <-> TZ Database Name Conversion Table

  Parameters:

  string tzName | The TZ Database name to convert.

  Throws:
  DateTimeException if the given tzName cannot be converted.

string windowsTZNameToTZDatabaseName(string tzName);
  Converts the given Windows time zone name to a corresponding TZ Database name.

  See Also:
  Windows <-> TZ Database Name Conversion Table

  Parameters:

  string tzName | The TZ Database name to convert.

  Throws:
  DateTimeException if the given tzName cannot be converted.

struct StopWatch;
  StopWatch measures time as precisely as possible.

  This class uses a high-performance counter. On Windows systems, it uses QueryPerformanceCounter, and on Posix systems, it uses clock_gettime if available, and gettimeofday otherwise.

  But the precision of StopWatch differs from system to system. It is impossible to for it to be the same from system to system since the precision of the system clock varies from system to system, and other system-dependent and situation-dependent stuff (such as the overhead of a context switch between threads) can also affect StopWatch's accuracy.

  Examples:

      void foo()
      {
          StopWatch sw;
          enum n = 100;
          TickDuration[n] times;
          TickDuration last = TickDuration.from!"seconds"(0);
          foreach(i; 0..n)
          {
             sw.start(); //start/resume mesuring.
             foreach(unused; 0..1_000_000)
                 bar();
             sw.stop();  //stop/pause measuring.
             //Return value of peek() after having stopped are the always same.
             writeln((i + 1) * 1_000_000, " times done, lap time: ",
                     sw.peek().msecs, "[ms]");
             times[i] = sw.peek() - last;
             last = sw.peek();
          }
          real sum = 0;
          // To know the number of seconds,
          // use properties of TickDuration.
          // (seconds, msecs, usecs, hnsecs)
          foreach(t; times)
             sum += t.hnsecs;
          writeln("Average time: ", sum/n, " hnsecs");
      }

  this(AutoStart autostart);
    Auto start with constructor.

  const pure nothrow @safe bool opEquals(const StopWatch rhs);
  const pure nothrow @safe bool opEquals(ref const StopWatch rhs);

  @safe void reset();
    Resets the stop watch.

  @safe void start();
    Starts the stop watch.

  @safe void stop();
    Stops the stop watch.

  const @safe TickDuration peek();
    Peek at the amount of time which has passed since the stop watch was started.

  @safe void setMeasured(TickDuration d);
    Set the amount of time which has been measured since the stop watch was started.

  const pure nothrow @property @safe bool running();
    Confirm whether this stopwatch is measuring time.

TickDuration[lengthof!fun()] benchmark(fun...)(uint n);
  Benchmarks code for speed assessment and comparison.

  Parameters:

  fun | aliases of callable objects (e.g. function names). Each should take no arguments.
  uint n | The number of times each function is to be executed.

  Returns:
  The amount of time (as a core.time.TickDuration) that it took to call each function n times. The first value is the length of time that it took to call fun[0] n times. The second value is the length of time it took to call fun[1] n times. Etc.

  Examples:

      int a;
      void f0() {}
      void f1() {auto b = a;}
      void f2() {auto b = to!(string)(a);}
      auto r = benchmark!(f0, f1, f2)(10_000);
      writefln("Milliseconds to call fun[0] n times: %s", r[0].msecs);

struct ComparingBenchmarkResult;
  Return value of benchmark with two functions comparing.

  const pure nothrow @property @safe real point();
    Evaluation value

    This returns the evaluation value of performance as the ratio of baseFunc's time over targetFunc's time. If performance is high, this returns a high value.

  const pure nothrow @property @safe TickDuration baseTime();
    The time required of the base function

  const pure nothrow @property @safe TickDuration targetTime();
    The time required of the target function

ComparingBenchmarkResult comparingBenchmark(alias baseFunc, alias targetFunc, int times = 4095)();
  Benchmark with two functions comparing.

  Parameters:

  baseFunc | The function to become the base of the speed.
  targetFunc | The function that wants to measure speed.
  times | The number of times each function is to be executed.

  Examples:

      void f1() {
         // ...
      }
      void f2() {
         // ...
      }

      void main() {
         auto b = comparingBenchmark!(f1, f2, 0x80);
         writeln(b.point);
      }

template isTimePoint(T)
  Whether the given type defines all of the necessary functions for it to function as a time point.

static pure nothrow bool yearIsLeapYear(int year);
  Whether the given Gregorian Year is a leap year.

  Parameters:

  int year | The year to to be tested.

pure nothrow long unixTimeToStdTime(time_t unixTime);
  Converts a time_t (which uses midnight, January 1st, 1970 UTC as its epoch and seconds as its units) to std time (which uses midnight, January 1st, 1 A.D. UTC and hnsecs as its units).

  Parameters:

  time_t unixTime | The time_t to convert.

pure nothrow time_t stdTimeToUnixTime(long stdTime);
  Converts std time (which uses midnight, January 1st, 1 A.D. UTC as its epoch and hnsecs as its units) to time_t (which uses midnight, January 1st, 1970 UTC as its epoch and seconds as its units). If time_t is 32 bits, rather than 64, and the result can't fit in a 32-bit value, then the closest value that can be held in 32 bits will be used (so time_t.max if it goes over and time_t.min if it goes under).

  Note:
  While Windows systems require that time_t be non-negative (in spite of time_t being signed), this function still returns negative numbers on Windows, since it's more flexible to allow negative time_t for those who need it. If on Windows and using the standard C functions or Win32 API functions which take a time_t, check whether the return value of stdTimeToUnixTime is non-negative.

  Parameters:

  long stdTime | The std time to convert.

SysTime SYSTEMTIMEToSysTime(const SYSTEMTIME* st, immutable TimeZone tz = LocalTime());
  This function is Windows-Only.

  Converts a SYSTEMTIME struct to a SysTime.

  Parameters:

  SYSTEMTIME* st | The SYSTEMTIME struct to convert.
  TimeZone tz | The time zone that the time in the SYSTEMTIME struct is assumed to be (if the SYSTEMTIME was supplied by a Windows system call, the SYSTEMTIME will either be in local time or UTC, depending on the call).

  Throws:
  DateTimeException if the given SYSTEMTIME will not fit in a SysTime, which is highly unlikely to happen given that SysTime.max is in 29,228 A.D. and the maximum SYSTEMTIME is in 30,827 A.D.

SYSTEMTIME SysTimeToSYSTEMTIME(in SysTime sysTime);
  This function is Windows-Only.

  Converts a SysTime to a SYSTEMTIME struct.

  The SYSTEMTIME which is returned will be set using the given SysTime's time zone, so to get the SYSTEMTIME in UTC, set the SysTime's time zone to UTC.

  Parameters:

  SysTime sysTime | The SysTime to convert.

  Throws:
  DateTimeException if the given SysTime will not fit in a SYSTEMTIME. This will only happen if the SysTime's date is prior to 1601 A.D.

long FILETIMEToStdTime(const FILETIME* ft);
  This function is Windows-Only.

  Converts a FILETIME struct to the number of hnsecs since midnight, January 1st, 1 A.D.

  Parameters:

  FILETIME* ft | The FILETIME struct to convert.

  Throws:
  DateTimeException if the given FILETIME cannot be represented as the return value.

SysTime FILETIMEToSysTime(const FILETIME* ft, immutable TimeZone tz = LocalTime());
  This function is Windows-Only.

  Converts a FILETIME struct to a SysTime.

  Parameters:

  FILETIME* ft | The FILETIME struct to convert.
  TimeZone tz | The time zone that the SysTime will be in (FILETIMEs are in UTC).

  Throws:
  DateTimeException if the given FILETIME will not fit in a SysTime.

FILETIME stdTimeToFILETIME(long stdTime);
  This function is Windows-Only.

  Converts a number of hnsecs since midnight, January 1st, 1 A.D. to a FILETIME struct.

  Parameters:

  sysTime | The SysTime to convert.

  Throws:
  DateTimeException if the given value will not fit in a FILETIME.

FILETIME SysTimeToFILETIME(SysTime sysTime);
  This function is Windows-Only.

  Converts a SysTime to a FILETIME struct.

  FILETIMEs are always in UTC.

  Parameters:

  SysTime sysTime | The SysTime to convert.

  Throws:
  DateTimeException if the given SysTime will not fit in a FILETIME.

alias DosFileTime = uint;
  Type representing the DOS file date/time format.

SysTime DosFileTimeToSysTime(DosFileTime dft, immutable TimeZone tz = LocalTime());
  Converts from DOS file date/time to SysTime.

  Parameters:

  DosFileTime dft | The DOS file time to convert.
  TimeZone tz | The time zone which the DOS file time is assumed to be in.

  Throws:
  DateTimeException if the DosFileTime is invalid.

DosFileTime SysTimeToDosFileTime(SysTime sysTime);
  Converts from SysTime to DOS file date/time.

  Parameters:

  SysTime sysTime | The SysTime to convert.

  Throws:
  DateTimeException if the given SysTime cannot be converted to a DosFileTime.

bool validTimeUnits(string[] units...);
  Whether all of the given strings are valid units of time.

  "nsecs" is not considered a valid unit of time. Nothing in std.datetime can handle precision greater than hnsecs, and the few functions in core.time which deal with "nsecs" deal with it explicitly.

int cmpTimeUnits(string lhs, string rhs);
  Compares two time unit strings. "years" are the largest units and "hnsecs" are the smallest.

  Returns:

  this < rhs | < 0
  this == rhs | 0
  this > rhs | > 0

  Throws:
  DateTimeException if either of the given strings is not a valid time unit string.

template CmpTimeUnits(string lhs, string rhs) if (validTimeUnits(lhs, rhs))
  Compares two time unit strings at compile time. "years" are the largest units and "hnsecs" are the smallest.

  This template is used instead of cmpTimeUnits because exceptions can't be thrown at compile time and cmpTimeUnits must enforce that the strings it's given are valid time unit strings. This template uses a template constraint instead.

  Returns:

  this < rhs | < 0
  this == rhs | 0
  this > rhs | > 0

pure nothrow bool valid(string units)(int value) if (units == "months" || units == "hours" || units == "minutes" || units == "seconds");
  Returns whether the given value is valid for the given unit type when in a time point. Naturally, a duration is not held to a particular range, but the values in a time point are (e.g. a month must be in the range of 1 - 12 inclusive).

  Parameters:

  units | The units of time to validate.
  int value | The number to validate.

  Examples:

      assert(valid!"hours"(12));
      assert(!valid!"hours"(32));
      assert(valid!"months"(12));
      assert(!valid!"months"(13));

pure nothrow bool valid(string units)(int year, int month, int day) if (units == "days");
  Returns whether the given day is valid for the given year and month.

  Parameters:

  units | The units of time to validate.
  int year | The year of the day to validate.
  int month | The month of the day to validate.
  int day | The day to validate.

pure void enforceValid(string units)(int value, string file = __FILE__, size_t line = __LINE__) if (units == "months" || units == "hours" || units == "minutes" || units == "seconds");
  Parameters:

  units | The units of time to validate.
  int value | The number to validate.
  string file | The file that the DateTimeException will list if thrown.
  size_t line | The line number that the DateTimeException will list if thrown.

  Throws:
  DateTimeException if valid!units(value) is false.

pure void enforceValid(string units)(int year, Month month, int day, string file = __FILE__, size_t line = __LINE__) if (units == "days");
  Parameters:

  units | The units of time to validate.
  int year | The year of the day to validate.
  Month month | The month of the day to validate.
  int day | The day to validate.
  string file | The file that the DateTimeException will list if thrown.
  size_t line | The line number that the DateTimeException will list if thrown.

  Throws:
  DateTimeException if valid!"days"(year, month, day) is false.

static pure int monthsToMonth(int currMonth, int month);
  Returns the number of months from the current months of the year to the given month of the year. If they are the same, then the result is 0.

  Parameters:

  int currMonth | The current month of the year.
  int month | The month of the year to get the number of months to.

static pure nothrow int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow);
  Returns the number of days from the current day of the week to the given day of the week. If they are the same, then the result is 0.

  Parameters:

  DayOfWeek currDoW | The current day of the week.
  DayOfWeek dow | The day of the week to get the number of days to.

auto measureTime(alias func)();
  Function for starting to a stop watch time when the function is called and stopping it when its return value goes out of scope and is destroyed.

  When the value that is returned by this function is destroyed, func will run. func is a unary function that takes a core.time.TickDuration.

  Examples:

      writeln("benchmark start!");
      {
      auto mt = measureTime!((a){assert(a.seconds);});
      doSomething();
      }
      writeln("benchmark end!");

Copyright 2010 - 2011 | Page generated by Ddoc.