#80 ✓resolved
amanfredi (at gmail)

2038 DateTime Problem

Reported by amanfredi (at gmail) | March 2nd, 2010 @ 01:07 PM | in Bugs

This is really a bug in ruby rather than sunspot, but I think the workaround is fairly easy.

On 32 bit systems, Time can't handle dates outside the 1901-2038 range. Rails helpfully converts these to DateTimes, but DateTime.xmlschema does not correctly add the trailing 'Z' required by solr's time format.

t = Time.parse('Apr 1, 2020') => Wed Apr 01 00:00:00 +0000 2020 t.class => Time t2 = t + 20.years => Sun, 01 Apr 2040 00:00:00 +0000 t2.class => DateTime t.utc.xmlschema => "2020-04-01T00:00:00Z" t2.utc.xmlschema => "2040-04-01T00:00:00+00:00"

Thus, I would recommend explicitly using strftime instead of the xmlschema method.

t2.utc.strftime("%Y-%m-%dT%H:%M:%SZ") => "2040-04-01T00:00:00Z"

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Awesome Solr interaction for Ruby

People watching this ticket

Referenced by