Example #1
0
        internal static StructTime GetDateTimeTuple(DateTime dt, PythonDateTime.PythonTimeZoneInformation tz, bool utc)
        {
            int last;
            if (utc) {
                last = 0;
            } else {
                if (tz == null) {
                    last = -1;
                } else {
                    PythonDateTime.PythonTimeDelta delta = tz.DaylightSavingTime(dt);
                    PythonDateTime.ThrowIfInvalid(delta, "dst");
                    if (delta == null) {
                        last = -1;
                    } else {
                        last = delta.NonZero() ? 1 : 0;
                    }
                }
            }

            return new StructTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, Weekday(dt), dt.DayOfYear, last);
        }
Example #2
0
File: time.cs Project: kashano/main
        internal static PythonTuple GetDateTimeTuple(DateTime dt, DayOfWeek? dayOfWeek, PythonDateTime.tzinfo tz) {
            int last = -1;

            if (tz == null) {
                last = -1;
            } else {
                PythonDateTime.timedelta delta = tz.dst(dt);
                PythonDateTime.ThrowIfInvalid(delta, "dst");
                if (delta == null) {
                    last = -1;
                } else {
                    last = delta.__nonzero__() ? 1 : 0;
                }
            }

            return new struct_time(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, Weekday(dayOfWeek ?? dt.DayOfWeek), dt.DayOfYear, last);
        }
Example #3
0
 internal static Tuple GetDateTimeTuple(DateTime dt, PythonDateTime.PythonTimeZoneInformation tz)
 {
     return GetDateTimeTuple(dt, tz, false);
 }