From: Rob Biedenharn Date: 2010-08-11T03:59:51+09:00 Subject: Re: Error: Bignum too big to convert into `long' On Aug 10, 2010, at 10:51 AM, Matt Mencel wrote: > Nope....that doesn't work either. > > def self.ad2time(timestamp) > # CONVERT NEVER EXPIRES 'accountExpires' NUMBER TO 12/31/2099 TO > GET AROUND BIGNUM PROBLEM ON SOLARIS > if timestamp == "9223372036854775807" > timestamp = "157468536000000000" > end > ad_epoch = 116_444_736_000_000_000 > ad_multiplier = 10_000_000 > Time.at((timestamp.to_i - ad_epoch) / ad_multiplier) > end > > I ran through the calculation in irb and get this... > > irb(main):003:0> 157468536000000000 - 116_444_736_000_000_000 > => 41023800000000000 > irb(main):004:0> 41023800000000000/10_000_000 > => 4102380000 > irb(main):005:0> Time.at(4102380000) > RangeError: bignum too big to convert into `long' > from (irb):5:in `at' > from (irb):5 > > > So Solaris can't even work with a date in this century? That's > bad.... > > > I ran the exact same numbers through irb on my Mac and it works just > fine... > >>> 157468536000000000 - 116_444_736_000_000_000 > => 41023800000000000 >>> 41023800000000000/10_000_000 > => 4102380000 >>> Time.at(4102380000) > => Thu Dec 31 00:00:00 -0600 2099 > > Another reason for me to dislike Solaris SPARC. > > Matt 32 bits of counting seconds since 1970 only gets you as far as 2038. You apparently dislike 32-bit systems and not just Solaris SPARC. -Rob > > ----- Original Message ----- > From: "Matt Mencel" > To: "ruby-talk ML" > Sent: Tuesday, August 10, 2010 8:40:54 AM > Subject: Re: Error: Bignum too big to convert into `long' > > Ah... > > 9223372036854775807 is the timestamp value assigned to the > "accountExpires" attribute in Active Directory when any account is > set to "Never Expire". > > It works fine on Linux/Mac but not on Solaris. I guess I'll just > convert that timestamp to something like 12/31/2099 23:59:59 before > I run the Time.at. > > Matt > > ----- Original Message ----- > From: "Brian Candler" > To: "ruby-talk ML" > Sent: Tuesday, August 10, 2010 7:53:24 AM > Subject: Re: Error: Bignum too big to convert into `long' > > Try your example values in irb: > > irb(main):003:0> (9223372036854775807 - 116_444_736_000_000_000) / > 10_000_000 > => 910692730085 > irb(main):004:0> Time.at(910692730085) > RangeError: bignum too big to convert into `long' > from (irb):4:in `at' > from (irb):4 > > Time.at expects number of seconds since Jan 1, 1970. > > The value you have given it is some time in the year 30,828 :-) > > I suspect either your epoch or your multiplier is wrong. > > B. > -- > Posted via http://www.ruby-forum.com/. > > > Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/