dec2date : Converts decimal dates to calendar dates.

This module was written by Arndt Piayda and then enhanced and maintained by Matthias Cuntz while at Department of Computational Hydrosystems, Helmholtz Centre for Environmental Research - UFZ, Leipzig, Germany, and continued by Matthias Cuntz while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.

Copyright (c) 2010-2020 Matthias Cuntz - mc (at) macu (dot) de Released under the MIT License; see LICENSE file for details.

  • Written Jun 2010 by Arndt Piayda
  • Input can be scalar, list, array, or mix of it, Feb 2012, Matthias Cuntz
  • Changed checks, added calendars decimal and decimal360, Feb 2012, Matthias Cuntz
  • fulldate=True default, Feb 2012, Matthias Cuntz
  • Change keyword name: units -> refdate, Jun 2012, Matthias Cuntz
  • units has now same meaning as in netcdftime, Jun 2012, Matthias Cuntz
  • Include cdo absolute date units ‘day as %Y%m%d.%f’, Jun 2012, Matthias Cuntz
  • Solved Excel leap year problem, Feb 2013, Matthias Cuntz
  • Ported to Python 3, Feb 2013, Matthias Cuntz
  • Small bug in eng output, May 2013, Arndt Piayda
  • Excel starts at 1 not at 0 on 01 January 1900 or 1904, Oct 2013, Matthias Cuntz
  • Bug: 01.01.0001 was substracted if Julian calendar even with units given, Oct 2013, Matthias Cuntz
  • Include units ‘month as %Y%m.%f’ and ‘year as %Y.%f’, May 2016, Matthias Cuntz
  • Adapted to new netCDF4/netcdftime (>= v1.0) and datetime (>= Python v2.7.9), Jun 2015, Matthias Cuntz
  • leap always integer, Oct 2016, Matthias Cuntz
  • Using numpy docstring format, May 2020, Matthias Cuntz
  • Succeed eng by en keyword as in ascii2ascii and date2dec, Jul 2020, Matthias Cuntz
  • proleptic_gregorian instead of gregorian calendar for Excel dates, Jul 2020, Matthias Cuntz

The following functions are provided

dec2date(indata[, calendar, refdate, units, …]) Converts scale and array_like with decimal dates into calendar dates.
dec2date(indata, calendar='standard', refdate=None, units=None, excelerr=True, fulldate=None, yr=False, mo=False, dy=False, hr=False, mi=False, sc=False, ascii=False, en=False, eng=False)[source]

Converts scale and array_like with decimal dates into calendar dates. Supported time formats are: standard, gregorian, julian, proleptic_gregorian, excel1900, excel1904, 365_day, noleap, 366_day, all_leap, and 360_day.

Input is decimal date in units of days.

Output is year, month, day, hour, minute, second or any combination of them. Output in string format is possible.

  • indata (array_like) – Input decimal dates. Dates must be positive.
  • calendar (str, optional) –

    Calendar of input dates (default: ‘standard’).

    Possible values are:

    ’standard’, ‘gregorian’ = julian calendar from 01.01.-4712 12:00:00 (BC) until 05.03.1583 00:00:00 and gregorian calendar from 15.03.1583 00:00:00 until now. Missing 10 days do not exsist.

    ’julian’ = julian calendar from 01.01.-4712 12:00:00 (BC)
    until now.

    ’proleptic_gregorian’ = gregorian calendar from 01.01.0001 00:00:00 until now.

    ’excel1900’ = Excel dates with origin at 01.01.1900 00:00:00.

    ’excel1904’ = Excel 1904 (Lotus) format. Same as excel1904 but with origin at 01.01.1904 00:00:00.

    ’365_day’, ‘noleap’ = 365 days format, i.e. common years only (no leap years) with origin at 01.01.0001 00:00:00.

    ’366_day’, ‘all_leap’ = 366 days format, i.e. leap years only (no common years) with origin at 01.01.0001 00:00:00.

    ’360_day’ = 360 days format, i.e. years with only 360 days (30 days per month) with origin at 01.01.0001 00:00:00.

    ’decimal’ = decimal year instead of decimal days.

    ’decimal360’ = decimal year with a year of 360 days, i.e. 12 month with 30 days each.