From: Matt Mencel on
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


----- Original Message -----
From: "Matt Mencel" <MR-Mencel(a)wiu.edu>
To: "ruby-talk ML" <ruby-talk(a)ruby-lang.org>
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" <b.candler(a)pobox.com>
To: "ruby-talk ML" <ruby-talk(a)ruby-lang.org>
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/.



From: Rob Biedenharn on
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" <MR-Mencel(a)wiu.edu>
> To: "ruby-talk ML" <ruby-talk(a)ruby-lang.org>
> 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" <b.candler(a)pobox.com>
> To: "ruby-talk ML" <ruby-talk(a)ruby-lang.org>
> 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(a)AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab(a)GaslightSoftware.com http://GaslightSoftware.com/


From: Brian Candler on
Matt Mencel wrote:
> 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.

The largest Time you can have in a 32-bit value is:

irb(main):001:0> Time.at(0x7fffffff)
=> Tue Jan 19 03:14:07 +0000 2038
irb(main):002:0> Time.at(0x7fffffff+1)
RangeError: bignum too big to convert into `long'
from (irb):2:in `at'
from (irb):2
from :0

Being Ruby, you are not constrained to using a numeric value. You could
use nil, or a symbol like :never, or a custom object which has
sufficient Time-like behaviours:

Never = Object.new
def Never.to_s; "Never"; end
--
Posted via http://www.ruby-forum.com/.