Date & time conversions used in the sciences.
The assumption is that datetimes are timezone-naive, as this is required in Numpy et al for numpy.datetime64
.
python -m pip install sciencedates
import sciencedates as sd
T = '2013-07-02T12'
yeardoy, utsec = sd.datetime2yd(T)
Results in year,DayOfYear; UTC fraction of day [seconds]
(2013102, 72000.0)
Julia examples are provided
Matlab / GNU Octave examples are provided
Fortran examples are provided. For Python-like modern Fortran datetime, see Datetime-Fortran.