[ruby-cvs:78760] 650c45dcd7 (ruby_2_6): merge revision(s) d6a2bce64a7fa1099e507e1d36b5f1533f42f60f,c687be4bc01c9ce52ea 990945d9304d6fe59fe9b: [Backport #16159]

"nagachika" <[email protected]>
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
nagachika	2019-12-18 22:41:48 +0900 (Wed, 18 Dec 2019)

  New Revision: 650c45dcd7

  https://github.com/ruby/ruby/commit/650c45dcd7

  Log:
    merge revision(s) d6a2bce64a7fa1099e507e1d36b5f1533f42f60f,c687be4bc01c9ce52ea990945d9304d6fe59fe9b: [Backport #16159]
    
    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]
    
    Added a test for [Bug #16159]
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

  Modified files:
    test/ruby/test_time_tz.rb
    time.c
    version.h
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.