sciris.sc_datetime.day

day(obj, *args, start_date=None, **kwargs)[source]

Convert a string, date/datetime object, or int to a day (int), the number of days since the start day. See also sc.date() and sc.daydiff(). If a start day is not supplied, it returns the number of days into the current year.

Parameters
  • obj (str, date, int, list, array) – convert any of these objects to a day relative to the start day

  • args (list) – additional days

  • start_date (str or date) – the start day; if none is supplied, return days since (supplied year)-01-01.

Returns

the day(s) in simulation time (matching input data type where possible)

Return type

days (int or list)

Examples:

sc.day(sc.now()) # Returns how many days into the year we are
sc.day(['2021-01-21', '2024-04-04'], start_date='2022-02-22') # Days can be positive or negative
New in version 1.0.0.
New in version 1.2.2: renamed “start_day” to “start_date”