Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work-week ends do not seem to be calculated correctly #49

Open
smemsh opened this issue Jul 28, 2021 · 2 comments · Fixed by #66
Open

work-week ends do not seem to be calculated correctly #49

smemsh opened this issue Jul 28, 2021 · 2 comments · Fixed by #66

Comments

@smemsh
Copy link
Contributor

smemsh commented Jul 28, 2021

Work week endings may be calculated incorrectly. Observe the following:

$ for ww in {s,e}o{,p,n}ww
  do printf "%s\t%s\n" $ww $(
      faketime '2017-03-05 12:34:56' task calc $ww
  ); done

soww    2017-03-13T00:00:00
sopww   2017-02-27T00:00:00
sonww   2017-03-13T00:00:00
eoww    2017-03-10T23:59:59
eopww   2017-03-03T23:59:59
eonww   2017-03-17T23:59:59

with the reference date of 2017-03-05 12:34:56 (a Sunday), and the calendar:

 $ ncal 03 2017
    March 2017        
Mo     6 13 20 27   
Tu     7 14 21 28   
We  1  8 15 22 29   
Th  2  9 16 23 30   
Fr  3 10 17 24 31   
Sa  4 11 18 25      
Su  5 12 19 26      
    9 10 11 12 13   

these do not look right:

  • It seems to consider the next "work week" to have already begun on Saturday, but I should think the next work week doesn't actually begin until Monday. Even though there's no actual work days left, it's still within the same work week.
  • soww and sonww are identical
  • eoww is earlier than soww (!)

This issue was noticed during testing for #47 (a change to comments documenting behavior of eo*) and is forked into a standalone issue as per the discussion there.

(test version of libshared was 591fa58)

@tbabej
Copy link
Member

tbabej commented Nov 9, 2021

Sigh. I said #66 partially resolves this, Github. We still need to fix / discuss the "It seems to consider the next "work week" to have already begun on Saturday" aspect of this bug report.

@tbabej tbabej reopened this Nov 9, 2021
@smemsh
Copy link
Contributor Author

smemsh commented Nov 20, 2021

These look correct now for weekend days such as today, except that eoww and eopww should not be the same:

 $ for ww in {s,e}o{,p,n}ww; do printf "%s\t%s\n" $ww $(
    faketime '2021-11-20 14:21:46' src/task calc $ww); done
soww    2021-11-15T00:00:00
sopww   2021-11-08T00:00:00
sonww   2021-11-22T00:00:00
eoww    2021-11-19T23:59:59
eopww   2021-11-19T23:59:59
eonww   2021-11-26T23:59:59

 $ ncal
    November 2021
Mo  1  8 15 22 29
Tu  2  9 16 23 30
We  3 10 17 24
Th  4 11 18 25
Fr  5 12 19 26
Sa  6 13 20 27
Su  7 14 21 28
   44 45 46 47 48

because, my assertion is, the next work week doesn't actually start until Monday, so the "previous" work week is still the one before this week's Monday. Even though it's after the end of the "work week" (I guess Friday), it's before the beginning of the next one..

All of the following task calc tests should be true, here below run with your patch:

 $ for test in "${tests[@]}"
   do printf "$test -> "; src/task calc "$test"; done
soww == (sonww - 7 days) -> true
eoww == (eonww - 7 days) -> true
(sopww + 7 days) == soww -> true
(eopww + 7 days) == eoww -> false

prior to your patch there were 3 false and a 1 true so it's closer ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants