Table: Comparison of DateTime classes in popular programming Languages Qingfeng Xia 2014 v0.2

Language / C std lib POSIX / Boost::datetime / QDateTime
QtCore / Java.util (deprecated),
JDK8 javax.time.* / Javascript / Python datetime
pytz
immutable Classes / Clock_t ()
uptime
time_t: (long type)
seconds since UNIX epoch: 1970-01-01Z / tzinfo,
ptime(datetime),
/ QDate QTime
Delta? / Instant(ns >=int64_t) UTCInstant (unix_time)
Duration(ns) (delta)
LocalDateTime, ZoneId
Period(date range ) / Should be, but net yet / 3rd party module:
Datetime
Mutable classes / struct tm * shared
gmtime(time_t* );
localtime(time_t *); / Gregorian::date, local_time, poxis_time time_duration/period
,iterator / QDateTime / Date (deprecated),
Calendar (old API) / Date
(=DateTime)
Date.set*() / Date, time
datetime
tzinfo
timedelta
Min-max
range / 1970-01-01 to
Year 2038 (int32_t),
no hassle to 64bit OS / Gregorian calendar
from year 1 / Julian Calendar
JulianDays() / ISO calendar system, -999999999-01-01 / +/-100,000,000 days relative to EPOCH / datetime.min=
Year 1
Year 9999
Resolution / TICKS_PER_SECOND clock() / Depends on building: millis, nanos / ? / Millisecond (<JDK7)
Nanosecond JDK8 / Millisecond
UTC() / microsecond
Get current
Time UTC / clock_t clock()
time_t time(NULL) / Boost::datetime second_clock.universal_time() / QDateTime QDatetime::toUTC() / Clock.systemUTC();
UTCInstant object / Date getUTC*() / datetime.utcnow()
date.utctoday()
LocalTime supported / need
env var, locale support / Boost::microsec_clock::local_time();
std::chrono::system_clock::now() / Give local time by default,QDateTime::currentDateTime() / LocalTime.now();Clock.systemDefaultZone(); / By default / Give local time by default
leap second / ? / ? / No leap second / ? / No / No leap second
Timezone
database / Not by std C
Posix tzset() / yes / No / Yes, ZonedDateTime
ZoneId ZoneOffset / Yes, tzinfo.utcoffset
Calendar gap / Can not represent to1582 Year / ? / Yes / No / Just like C / No, using extended Greg.

C++11 <chrono.h> in namespace std::chrono, has NOT timezone support in std::chrono: time_point,duration, 3 clocks

Python: datetime classes are mutable! timedelta(days, seconds, microseconds) be careful of this constructor parameter

JDK 8 toString format

Class or Enum / Year / Month / Day / Hours / Minutes / Seconds* / Zone Offset / Zone ID / toString Output / Where Discussed
Instant / / 2013-08-20T15:16:26.355Z / Instant Class
LocalDate / / / / 2013-08-20 / Date Classes
LocalDateTime / / / / / / / 2013-08-20T08:16:26.937 / Date and Time Classes
ZonedDateTime / / / / / / / / / 2013-08-21T00:16:26.941+09:00[Asia/Tokyo] / Time Zone and Offset Classes
LocalTime / / / / 08:16:26.943 / Date and Time Classes
MonthDay / / / --08-20 / Date Classes
Year / / 2013 / Date Classes
YearMonth / / / 2013-08 / Date Classes
Month / / AUGUST / DayOfWeek and Month Enums
OffsetDateTime / / / / / / / / 2013-08-20T08:16:26.954-07:00 / Time Zone and Offset Classes
OffsetTime / / / / / 08:16:26.957-07:00 / Time Zone and Offset Classes
Duration / ** / ** / ** / / PT20H (20 hours) / Period and Duration
Period / / / / *** / *** / P10D (10 days) / Period and Duration
* / Seconds are captured to nanosecond precision.
** / This class does not store this information, but has methods to provide time in these units.
*** / When a Period is added to a ZonedDateTime, daylight saving time or other local time differences are observed.