diff options
| author | Yusuke Endoh <mame@ruby-lang.org> | 2019-12-17 10:31:20 +0900 |
|---|---|---|
| committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-12-17 10:36:20 +0900 |
| commit | d6a2bce64a7fa1099e507e1d36b5f1533f42f60f (patch) | |
| tree | a4fec2936059a9fab247890489835b8a1eda1f15 /lib/net/https.rb | |
| parent | 5da4a310ccf7f4131c1814a2c9279a5682777f1b (diff) | |
time.c (find_time_t): fix round-to-zero bug
`find_time_t` did not work correctly for year older than the Epoch
because it used C's integer division (which rounds negative to zero).
For example, `TIme.new(1933)` returned a wrong time whose year is 1922
in Asia/Kuala_Lumpur because there is no 00:00:00 1st Jan. 1933 in the
time zone.
```
$ TZ=Asia/Kuala_Lumpur ruby -e 'p Time.new(1933)'
1932-12-31 00:00:00 +0700
```
This change fixes the issue by using `DIV` macro instead of `/`.
Now `Time.new(1933)` returns a time in 1933.
```
$ TZ=Asia/Kuala_Lumpur ruby -e 'p Time.new(1933)'
1933-01-01 00:20:00 +0720
```
[Bug #16159]
Diffstat (limited to 'lib/net/https.rb')
0 files changed, 0 insertions, 0 deletions
