# Time range min/max inconsistency

**URL:** <https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652>\
**Category:** Ruby\
**Created:** [July 17, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652 "2007-07-17T16:09:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 17, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/1 "2007-07-17T16:09:27Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi!

I created a range of Time objects. My problem (?) is, that the range’s  
min() and max() methods return their values in a different format.

I made the following test:

?\> t1 = Time.utc(2007,7,17,10,00)  
=\> Tue Jul 17 10:00:00 UTC 2007

> > t2 = Time.utc(2007,7,17,12,00)  
> > =\> Tue Jul 17 12:00:00 UTC 2007

> > r=(t1…t2)  
> > =\> Tue Jul 17 10:00:00 UTC 2007…Tue Jul 17 12:00:00 UTC 2007

> > r.min  
> > =\> Tue Jul 17 10:00:00 UTC 2007

> > r.max  
> > =\> Tue Jul 17 14:00:00 +0200 2007

As you may see r.max returns the correct value, however it is in a  
different time format as r.min’s return value (and different from the  
initial value).

If I use these values in a user interface, the max value must be  
converted to a UTC time with r.max.utc before i can format it with  
strftime().

Do you think this is a bug, or should i read more ruby literature? 🙂

I’m pretty new to ruby, so please don’t slap me in the face for this. 🙂

Thank you,  
Chris

* * *

Fischer  
KrisztiánBorganization Kft.  
Tel: (+36) 70/384-383-5  
Tel: (+36) 1/3360547  
email: removed\_email\_address@domain.invalid  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGnMz46VUohGTtAQYRAl76AJ4jZH+mHmJzQWqn17GUJAl6yDi8lgCgxBZj  
anm75OzaJYA1v1hQyrh+w3Y=  
=cXVu  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 12:44am UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/2 "2007-07-18T00:44:46Z")

</div>

> Do you think this is a bug, or should i read more ruby literature? 🙂

I don’t know if this is related to your problem, but whenever I use  
Marshal.load to load a marshaled Time object, it’s always created in the  
local timezone, regardless of what zone the saved object was in. This  
is similar behavior, although I’m pretty sure Ranges don’t use Marshal,  
and it’s weird that it’s just the max.

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 1:30am UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/3 "2007-07-18T01:30:54Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Brett S. wrote:

> > =\> Tue Jul 17 14:00:00 +0200 2007  
> > I don’t know if this is related to your problem, but whenever I use  
> > Marshal.load to load a marshaled Time object, it’s always created in the  
> > local timezone, regardless of what zone the saved object was in. This  
> > is similar behavior, although I’m pretty sure Ranges don’t use Marshal,  
> > and it’s weird that it’s just the max.

Thanks for the answer.

Seems to me like timezone is the black sheep in ruby. Today I ran into  
the problem described above, and shortly after this into an other one.

If you store a UTC time in mysql via rails’ ActiveRecord and read it  
back, the local timezone is added to the time, which is pretty strange.

I could fix the problem with a small hack, however as a ruby newbie it  
took me a day to figure this out. 🙂

Thanks,  
Chris

* * *

Fischer  
KrisztiánBorganization Kft.  
Tel: (+36) 70/384-383-5  
Tel: (+36) 1/3360547  
email: removed\_email\_address@domain.invalid  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGnVEA6VUohGTtAQYRAjR8AJ0UbIKu37o/ikmuqzsSWKmgAk11+gCeKl8H  
08K2vUyDVr1giGzH+Tb88sc=  
=RX1m  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 1:55am UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/4 "2007-07-18T01:55:55Z")

</div>

Hi,

In message “Re: Time range min/max inconsistency”  
on Tue, 17 Jul 2007 23:07:04 +0900, Fischer  
Krisztián [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|I created a range of Time objects. My problem (?) is, that the range’s  
|min() and max() methods return their values in a different format.  
|  
|I made the following test:  
|  
|?\> t1 = Time.utc(2007,7,17,10,00)  
|=\> Tue Jul 17 10:00:00 UTC 2007  
|  
|\>\> t2 = Time.utc(2007,7,17,12,00)  
|=\> Tue Jul 17 12:00:00 UTC 2007  
|  
|\>\> r=(t1…t2)  
|=\> Tue Jul 17 10:00:00 UTC 2007…Tue Jul 17 12:00:00 UTC 2007  
|  
|\>\> r.min  
|=\> Tue Jul 17 10:00:00 UTC 2007  
|  
|\>\> r.max  
|=\> Tue Jul 17 14:00:00 +0200 2007

You’ve found a bug in Ruby. It’s fixed in the repository.  
Thank you for the report.

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 2:01am UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/5 "2007-07-18T02:01:55Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

Yukihiro M. wrote:

> You’ve found a bug in Ruby. It’s fixed in the repository.

Thanks for the fast answer, and for Ruby. 🙂

> Thank you for the report.

It was a pleasure. 🙂

Chris

* * *

Fischer  
KrisztiánBorganization Kft.  
Tel: (+36) 70/384-383-5  
Tel: (+36) 1/3360547  
email: removed\_email\_address@domain.invalid  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGnVgd6VUohGTtAQYRAj7GAKCHBjPqncLmIhu7lPVcn85/7PYhbwCgiMuN  
RA9k5cb3v/4HRI3C+5htM/I=  
=9Zda  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 6:47am UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/6 "2007-07-18T06:47:40Z")

</div>

From: Yukihiro M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

# |?\> t1 = Time.utc(2007,7,17,10,00)

# |=\> Tue Jul 17 10:00:00 UTC 2007

# |

# |\>\> t2 = Time.utc(2007,7,17,12,00)

# |=\> Tue Jul 17 12:00:00 UTC 2007

# |

# |\>\> r=(t1…t2)

# |=\> Tue Jul 17 10:00:00 UTC 2007…Tue Jul 17 12:00:00 UTC 2007

# |

# |\>\> r.min

# |=\> Tue Jul 17 10:00:00 UTC 2007

# |

# |\>\> r.max

# |=\> Tue Jul 17 14:00:00 +0200 2007

# 

# You’ve found a bug in Ruby. It’s fixed in the repository.

# Thank you for the report.

matz, i find the ruby src/test very helpful. Is \*updating the ruby  
src/test available for the public or only for ruby-core?

kind regards -botp

---

<div class="post-metadata">

**Author:** ![Fischer\_KrisztiSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@Fischer\_KrisztiSSSS](https://www.ruby-forum.com/u/Fischer_KrisztiSSSS)\
**Post date:** [July 18, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/time-range-min-max-inconsistency/109652/7 "2007-07-18T16:56:16Z")

</div>

Hi,

In message “Re: Time range min/max inconsistency”  
on Wed, 18 Jul 2007 13:46:24 +0900, “Pena, Botp”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|matz, i find the ruby src/test very helpful. Is \*updating the ruby src/test available for the public or only for ruby-core?

If you submit a patch for the test (preferable to the ruby-core list),  
it is likely to be committed to the repository, by any of our  
committers (perhaps me).

```
          matz.

```
