Skip to content

Fix Daylight Savings parsing

Stan Hu requested to merge sh-fix-daylight-savings-parsing-gitlab into master

Previously the offset change for Daylight Savings was unnecessarily added all the time, resulting in this discrepancy when the local time was set to UTC-7:

Time.parse('2020-11-01 00:00:00')
=> 2020-11-01 00:00:00 -0700
Chronic.parse('2020-11-01 00:00:00')
=> 2020-11-01 01:00:00 -0700

Each time we add an offset to a base time, we need to check whether this crosses Daylight Savings boundaries. Only if it does should we adjust the time by the offset.

Closes https://github.com/mojombo/chronic/issues/147

Identified in gitlab-org/gitlab#37014 (closed)

Edited by Stan Hu

Merge request reports