tf_quant_finance.datetime.utils.days_in_leap_and_nonleap_years_between

Contents

Last updated: 2023-03-16.

tf_quant_finance.datetime.utils.days_in_leap_and_nonleap_years_between#

View source

Calculates number of days that fall on leap and non-leap years.

tf_quant_finance.datetime.utils.days_in_leap_and_nonleap_years_between(
    start_date, end_date
)

Calculates a tuple ‘(days_in_leap_years, days_in_nonleap_years)’. ‘start_date’ is included and ‘end_date’ is excluded from the period.

For example, for dates 2019-12-24 and 2024-2-10 the result is (406, 1103): 406 = 366 days in 2020 + 31 in Jan 2024 + 9 in Feb 2024, 1103 = 8 in 2019 + 365 in 2021 + 365 in 2022 + 365 in 2023.

If end_date is earlier than start_date, the result will be negative or zero.

Args:#

  • start_date: DateTensor.

  • end_date: DateTensor compatible with start_date.

Returns:#

Tuple of two Tensors of type ‘int32’.