0

My timezone is IST, +0530. It shows the correct zone if I pass arguments with recent years:

Time.new('2000', '02', '29')    # => 2000-02-29 00:00:00 +0530

But the zone changes for years like these:

Time.new('1000', '01', '29')    # => 1000-01-29 00:00:00 +0553
Time.new('1943')                # => 1943-01-01 00:00:00 +0630
Time.new('1871')                # => 1871-01-01 00:00:00 +0521

To find out the previous dates, I created a loop:

puts 2_200.times.map { |i| Time.new(i.to_s) }

As I can see for the years in the future, the zone is +0530, but for past centuries, the zone is sometime differs!

Why does the zone differ in the same system?

phuclv
  • 37,963
  • 15
  • 156
  • 475
15 Volts
  • 1,946
  • 15
  • 37
  • 4
    Timezones change historically. Not uncommon during war periods for instance. https://en.wikipedia.org/wiki/Time_in_India#Recorded_history – Mat Jun 10 '19 at 15:40
  • I actually didn't know that. BTW, are the values hard coded into Ruby? – 15 Volts Jun 10 '19 at 15:41
  • 4
    https://en.wikipedia.org/wiki/Tz_database – Mat Jun 10 '19 at 15:44
  • @Mat, that makes for very interesting reading. One [footnote](https://en.wikipedia.org/wiki/Tz_database#cite_note-34) (at the Tz_database link) caught my eye, concerning a threatened copyright lawsuit. – Cary Swoveland Jun 10 '19 at 16:10
  • Anyways, it's not Ruby, the date command in my system prints the same output!! `date -d 1943/11/24 +%z` prints +0630... – 15 Volts Jun 10 '19 at 17:46
  • [Why is subtracting these two times (in 1927) giving a strange result?](https://stackoverflow.com/q/6841333/995714) – phuclv Sep 11 '20 at 07:10
  • Does this answer your question? [Why is subtracting these two times (in 1927) giving a strange result?](https://stackoverflow.com/questions/6841333/why-is-subtracting-these-two-times-in-1927-giving-a-strange-result) – phuclv Sep 11 '20 at 07:12
  • I have no idea about Java. Java is not Ruby. – 15 Volts Sep 11 '20 at 18:03

1 Answers1

1

Why does the zone differ in the same system?

Because time zones change over time.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653