From: Chris W. <ch...@cw...> - 2002-02-13 15:58:45
|
On Wed, 2002-02-13 at 10:40, Al Lilianstrom wrote: > I'm working with Active Directory manipulation from a Unix machine. > We're going to have a centralized Oracle database feed my code to create > accounts in AD. One of the items we want to set is the accountExpires > field - esp for contractors. According to the schema this value is > stored as a large integer that represents the number of seconds elapsed > since 00:00:00, January 1, 1970. > > It's real easy to get the number of seconds since Jan 1, 1970. But I'm > unsure what this large integer format is and how to convert to it. This is a common unix way to identify time. Jan 1, 1970 is known as the epoch. Being of a unix heritage, Perl can translate to and from epoch seconds easily: From: my $time_sec = get_epoch_seconds(); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( $time_sec ); To: use Time::Local; my $time_sec = timelocal($sec,$min,$hours,$mday,$mon,$year); Note that $mon is a 0 offset value (0..11) in both cases. The $year value returned from localtime() needs 1900 added to it to be a human-readable value (e.g., this year localtime returns 102: 102 + 1900 = 2002). The timelocal() function is a little more flexible and can take either a 1900-offset value or a four-digit year. localtime() is a built-in function (see 'perldoc -f localtime') and Time::Local is distributed with all modern (5.6+) versions of Perl. I recently had to answer this for some of my win32 colleagues, so this is very much in the front of my mind :-) Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |