10.02.2017 14:15, drug пишет:
unittest
{
    import std.datetime : SysTime, UTC;

    {
        auto st = SysTime();
        st.timezone(UTC());

        long date  = st.fromISOExtString("2017-02-10T00:00:00Z").stdTime,
            time_of_day =
st.fromISOExtString("0000-01-01T23:59:50Z").stdTime,
            timestamp   =
st.fromISOExtString("0000-01-01T23:59:55Z").stdTime;

        import std.stdio;
        st.stdTime(date);
        writeln(st);
        st.stdTime(timestamp);
        writeln(st);
        st.stdTime(date+timestamp);
        writeln(st);
    }
}

prints
```
2017-Feb-10 00:00:00Z
0000-Jan-01 23:59:55Z
2016-Feb-10 23:59:55Z
```
I expect
```
2017-Feb-10 00:00:00Z
0000-Jan-01 23:59:55Z
2017-Feb-10 23:59:55Z
```

Why does it decrement years? What do I do wrong?
I found error - years should start from 1, not 0.
But if months or days start from 0 std.datetime throws exception and don't for years - it isn't clear that zero year is negative one (in that mean that stdTime for '0000' years will be negative.

Reply via email to