Skip to content

TimeBackground

Richard Hattersley edited this page Oct 15, 2013 · 4 revisions

Comments on various relevant technologies.

datetime

  • Only supports a year range of [1, 9999], but UDUNITS allows [-9999, 9999].

datetime360

Without an established standard reference, the concept of day-of-week is not well defined. Similarly, the proleptic-Gregorian ordinal is also not well defined.

Implementation

  • Why is it limited to a year range of [1, 9999]?
  • Can we drop the time zone component?
  • datetime360.date:
  • Class methods dropped: today, fromtimestamp, fromordinal
  • Methods dropped: timetuple, toordinal, weekday, isoweekday, isocalenday, isoformat (just use __str__), ctime
  • Methods modified: strftime (some format directives are not valid)
  • datetime360.datetime:
  • Class methods dropped: now, utcnow, fromtimestamp, utcfromtimestamp
  • Methods dropped: timetz, ctime, timetuple, utctimetuple, isoformat, utcoffset, tzname, dst, astimezone
  • Class methods modified: strptime (some format directives are not valid)
  • Missing methods: strftime

NumPy

  • Extend via custom dtype.

  • Version 1.6 (but seemingly not 1.5 or 1.7) has a bug which prevents user-defined dtypes from participating in standard ufuncs.

  • Version 1.7+ will not automatically create arrays of the right dtype unless the scalar type is a subclass of np.generic. This would add an awkward asymmetry if we define our own dtype for Gregorian datetimes using datetime.datetime as the scalar. Similarly, it makes it awkward to define a our own dtype for datetime.timedelta.

  • Instead of datetime.timedelta (which has a range of ~280000 years in a 360-day calendar, and microsecond resolution), we could use np.timedelta64[us] (which has a range of ~290000 years w/ microsecond resolution).

  • Should we use np.datetime64 instead of datetime.datetime? Should we always use microsecond resolution?

pandas

  • Array DateTimeIndex is a subclass of ndarray
  • Always uses M8[ns] so has a range of 1970 +/-292 years.
  • Extra attributes/methods to provide access to day, month, convert to datetime.datetime, etc.
  • Extra metadata to record "frequency" and time zone.
  • Scalar Timestamp is a subclass of datetime.datetime
  • Extra resolution to record nanoseconds
  • Extra metadata to record "frequency"
  • https://groups.google.com/forum/#!topic/pydata/JgCgQGpgkC8
Clone this wiki locally