offset_for_local_datetime: Add a 'ignore_missing_spans' argument#26
offset_for_local_datetime: Add a 'ignore_missing_spans' argument#26wolfsage wants to merge 1 commit intohouseabsolute:masterfrom
Conversation
| # return the previous span so the offset to utc is higher, | ||
| # effectively moving the time forward whatever the difference | ||
| # in the two spans is (typically 1 hour for DST). | ||
| return $self->{spans}[ $i - 1 ] if $ignore_missing_spans; |
There was a problem hiding this comment.
Is $i - 1 good enough (since $i can be > $max, not just == $max) ...
If this is true and the local time for the given $dt object does not exist in the time zone (due to DST changes for example), the previous span will be returned.
aac937e to
1f28fa7
Compare
autarch
left a comment
There was a problem hiding this comment.
This failed the Travis tests because the code is not passing the tidyall check. See the contributing doc for details on how to fix this.
| when the corresponding UTC time is not yet known, because local times | ||
| can be ambiguous due to Daylight Saving Time rules. | ||
|
|
||
| If C<$ignore_missing_spans> is true and the local time for C<$dt> does not |
There was a problem hiding this comment.
I wonder if it makes sense to document this talking about "spans". Note that the docs do not mention this term at all, because it's really just an internal detail.
I think this might be better presented as $fall_forward_on_skipped_time or something like that. Saying "the next span up" seems wrong too. Aren't we going to the previous span? But anyway, I'd say something like this:
If
$fall_back_on_skipped_timeis true and the local time for C<$dt> does not exist in the time zone (typically because of a DSST change), then we will fall back to nearest previous offset for the local time.
There was a problem hiding this comment.
Hmm, we're going to the previous span but that moves the time forward, so I'd add to the above ...
Note that moving to a previous offset will typically move the time forward, since the new offset from UTC will be larger.
If this is true and the local time for the given $dt object does
not exist in the time zone (due to DST changes for example), the previous
span will be returned.