From 3044ba6fd7520cedf4aa4df747b20c1bf077ac15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 20 Sep 2022 22:29:57 +0200 Subject: [PATCH] more docs --- .../Base/0.0.0-dev/src/Data/Time/Date.enso | 15 +++++++++++++++ .../0.0.0-dev/src/Data/Time/Date_Time.enso | 18 ++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso index 18be428b1c8a5..f89771fa92986 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso @@ -317,6 +317,21 @@ type Date For the purpose of this method, the business days are defined to be Monday through Friday. + This method always returns a day which is a business day - if the shift + amount is zero, the closest following business day is returned. For the + purpose of calculating the shift, the holidays are treated as if we were + starting at the next business day after them, for example counting the + shift starting on Saturday or Sunday works as if we were counting the + shift from Monday (for positive shifts). So shifting Sunday by zero days + will return Monday, but shifting it by one day will return a Tuesday + (so that there is the full work day - Monday) within the interval. For + negative shifts, shifting either Saturday or Sunday one day backwards + will return Friday, but shifting Monday one day backwards will return a + Friday. The whole logic is made consistent with `work_days_until`, so + that the following properties hold: + date.work_days_until (date.add_work_days N) == N for any N >= 0 + (date.add_work_days N).work_days_until date == -N for any N < 0 + Arguments: - amount: The number of business days to shift the date by. If `amount` is zero, the current date is returned, unless it is a weekend or a diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Time.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Time.enso index 7f557249e2624..cba775f30af00 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Time.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Time.enso @@ -397,8 +397,22 @@ type Date_Time For the purpose of this method, the business days are defined to be Monday through Friday. - The time of day is preserved, only the date is shifted. If the time of - day is not valid for the new date (DST gaps), TODO + This method always returns a day which is a business day - if the shift + amount is zero, the closest following business day is returned. For the + purpose of calculating the shift, the holidays are treated as if we were + starting at the next business day after them, for example counting the + shift starting on Saturday or Sunday works as if we were counting the + shift from Monday (for positive shifts). So shifting Sunday by zero days + will return Monday, but shifting it by one day will return a Tuesday + (so that there is the full work day - Monday) within the interval. For + negative shifts, shifting either Saturday or Sunday one day backwards + will return Friday, but shifting Monday one day backwards will return a + Friday. The whole logic is made consistent with `work_days_until`, so + that the following properties hold: + date.work_days_until (date.add_work_days N) == N for any N >= 0 + (date.add_work_days N).work_days_until date == -N for any N < 0 + + The time of day is preserved, only the date is shifted. Arguments: - amount: The number of business days to shift the date by. If `amount`