meteociel.utils.get_seconds
- meteociel.utils.get_seconds(date: datetime, ref_string: str = '1970-01-01 01:00', ref_fmt: str = '%Y-%m-%d %H:%M')
Compute the elapsed seconds since a given reference time (by default epoch).
Parameters
- date
datetime Date up to which the number of elapsed seconds is to be calculated.
- ref_string
str, optionnal By default:
"1970-01-01 01:00"(epoch). The time to be used as reference for calculations.- ref_fmt
str, optionnal By default:
"%Y-%m-%d %H:%M". The format to be used to readref_string. For more information on format codes, please see thedatetimedocumentation
Returns
- out
int The number of elapsed seconds between the reference and the given time.
Exemples
This exemple computes the number of elapsed seconds between epoch and 2022/08/18 00h GMT:
>>> from datetime import datetime >>> from meteociel import utils >>> utils.get_seconds(datetime.strptime("2022-08-18 00", "%Y-%m-%d %H")) 1660777200
- date