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

Fix: Also convert dates for nextDate comparisons #3818

Merged
merged 6 commits into from
Aug 15, 2023

Conversation

mattmundell
Copy link
Contributor

@mattmundell mattmundell commented Jul 25, 2023

What

In Event.nextDate convert dates with the timezone before comparing to now. This is similar to converting the dates before returning them.

Why

The dates have floating timezones so they need to be converted, else they are treated as UTC when being converted to Unix time.

To reproduce:

  1. set machine tz to America/Los_Angeles
  2. faketime '2022-12-05 08:15:42' gsad...
  3. faketime '2022-12-05 08:15:42' gvmd...
  4. create schedule with this

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//XXX//NONSGML//EN
BEGIN:VEVENT
DTSTART;TZID=/America/New_York:20221220T000100
RRULE:FREQ=MONTHLY;BYDAY=3WE;
END:VEVENT
END:VCALENDAR

  1. export TZ=America/New_York
  2. faketime '2023-02-14 17:56' some_web_browser
  3. GSA menu: Configuration > Schedules
  4. Next Run is in March but should be in Feb

To also confirm that task starts:

  1. In a VM:
  2. sudo timedatectl set-timezone America/Los_Angeles
  3. sudo service postgresql stop
  4. sudo date --set="20 December 2022 07:00:00" # 10:00:00 NY create
  5. sudo service postgresql start
  6. start gsa and gvmd and browser
  7. GSA > Schedules > New > Custom > Monthly > Wednesday, with TZ America/New_York and first run 0:01
  8. kill gsa,gvmd,browser
  9. sudo service postgresql stop
  10. sudo date --set="14 February 2023 20:56:00" # 23:56:00 NY just before issue
  11. sudo service postgresql start
  12. start gsa,gvmd,brower
  13. note that Next Run column in GSA has March
  14. tail -F ~/alts/main/var/log/gvm/gvmd.log # watch for task start

References

Closes /greenbone/gvmd/issues/1911.
GEA-114

Checklist

  • Tests

@github-actions
Copy link

github-actions bot commented Jul 25, 2023

Conventional Commits Report

Type Number
Added 1
Bug Fixes 1

🚀 Conventional commits found.

@bjoernricks bjoernricks marked this pull request as ready for review July 25, 2023 14:28
@bjoernricks bjoernricks requested a review from a team as a code owner July 25, 2023 14:28
@bjoernricks bjoernricks marked this pull request as draft July 25, 2023 14:28
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #3818 (14d3ade) into main (ec72a76) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 14d3ade differs from pull request most recent head 19f1153. Consider uploading reports for the commit 19f1153 to get more accurate results

@@           Coverage Diff           @@
##             main    #3818   +/-   ##
=======================================
  Coverage   60.09%   60.09%           
=======================================
  Files        1023     1023           
  Lines       25153    25152    -1     
  Branches     7436     7434    -2     
=======================================
+ Hits        15115    15116    +1     
+ Misses       9096     9094    -2     
  Partials      942      942           
Files Changed Coverage Δ
src/gmp/models/event.js 69.58% <100.00%> (+0.15%) ⬆️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mattmundell mattmundell marked this pull request as ready for review August 11, 2023 21:39
@timopollmeier timopollmeier merged commit ac0ac87 into greenbone:main Aug 15, 2023
8 checks passed
@mattmundell mattmundell deleted the sched-recurr-tz branch August 15, 2023 13:20
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 this pull request may close these issues.

3 participants