internal datetime(DateTime dt, int lostMicroseconds, tzinfo tzinfo) { this.InternalDateTime = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second); this._lostMicroseconds = dt.Millisecond * 1000 + lostMicroseconds; this._tz = tzinfo; // make sure both are positive, and lostMicroseconds < 1000 if (_lostMicroseconds < 0) { try { InternalDateTime = InternalDateTime.AddMilliseconds(_lostMicroseconds / 1000 - 1); } catch { throw PythonOps.OverflowError("date value out of range"); } _lostMicroseconds = _lostMicroseconds % 1000 + 1000; } if (_lostMicroseconds > 999) { try { InternalDateTime = InternalDateTime.AddMilliseconds(_lostMicroseconds / 1000); } catch { throw PythonOps.OverflowError("date value out of range"); } _lostMicroseconds = _lostMicroseconds % 1000; } }
public datetime([NotNull]string str, [NotNull]tzinfo tzinfo) : this(str) { _tz = tzinfo; }
private void Initialize(int year, int month, int day, int hour, int minute, int second, int microsecond, tzinfo tzinfo) { }
public datetime(int year, int month, int day, [DefaultParameterValue(0)]int hour, [DefaultParameterValue(0)]int minute, [DefaultParameterValue(0)]int second, [DefaultParameterValue(0)]int microsecond, [DefaultParameterValue(null)]tzinfo tzinfo) { PythonDateTime.ValidateInput(InputKind.Year, year); PythonDateTime.ValidateInput(InputKind.Month, month); PythonDateTime.ValidateInput(InputKind.Day, day); PythonDateTime.ValidateInput(InputKind.Hour, hour); PythonDateTime.ValidateInput(InputKind.Minute, minute); PythonDateTime.ValidateInput(InputKind.Second, second); PythonDateTime.ValidateInput(InputKind.Microsecond, microsecond); InternalDateTime = new DateTime(year, month, day, hour, minute, second, microsecond / 1000); _lostMicroseconds = microsecond % 1000; _tz = tzinfo; }
internal static bool IsNaiveTimeZone(tzinfo tz) { if (tz == null) return true; if (tz.utcoffset(null) == null) return true; return false; }
internal time(TimeSpan timeSpan, int lostMicroseconds, tzinfo tzinfo) { this._timeSpan = timeSpan; this._lostMicroseconds = lostMicroseconds; this._tz = tzinfo; }
public time([DefaultParameterValue(0)]int hour, [DefaultParameterValue(0)]int minute, [DefaultParameterValue(0)]int second, [DefaultParameterValue(0)]int microsecond, [DefaultParameterValue(null)]tzinfo tzinfo) { PythonDateTime.ValidateInput(InputKind.Hour, hour); PythonDateTime.ValidateInput(InputKind.Minute, minute); PythonDateTime.ValidateInput(InputKind.Second, second); PythonDateTime.ValidateInput(InputKind.Microsecond, microsecond); // all inputs are positive this._timeSpan = new TimeSpan(0, hour, minute, second, microsecond / 1000); this._lostMicroseconds = microsecond % 1000; this._tz = tzinfo; }
public datetime(DateTime dt, tzinfo tzinfo) : this(dt, (int)((dt.Ticks / TicksPerMicrosecond) % 1000), tzinfo) { }