Re: Date function



boyd wrote:
In article <4t3qsqF11g6o6U2@xxxxxxxxxxxxxxxxxx>,
Gunnar Hjalmarsson <noreply@xxxxxxxxx> wrote:
boyd wrote:
something like:

my( $day, $mon, $yr ) = ( localtime( time - 24*3600) )[3, 4, 5];
$yr += 1900;
$mon += 1;
my $str = sprintf '%4d-%02d-%02d', $yr, $mon, $day;

would give you the prefix string for your filename.

What about DST? ;-)

Good point. So my method would mess up on one of the DST changeovers if it ran between midnight and 0100 local. Is that right?

Yeah, that's what I'm thinking of. Maybe not a disaster in this case, but always worth considering when dealing with dates.

What is the "40000" for in your script?

That's 'approximately' 12 hours, i.e. well enough time to make the result DST safe. :)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.



Relevant Pages

  • Re: ways to change the first char from a filename (with full path)
    ... Gunnar Hjalmarsson wrote: ... > Rod Za wrote: ... >> change the first char of the filename. ...
    (perl.beginners)
  • Re: Regular expression
    ... > I want to split the filename and the path. ... > as input to fetch the file from a remote machine through ftp.. ... > with the slashes in it.. ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)
  • Re: Compare two files
    ... Jeff Pang wrote: ... ls -la May 12 2003 filename ... I would use stat, localtime() and timelocalinstead. ... Gunnar Hjalmarsson ...
    (perl.beginners)
  • Re: Date function
    ... boyd wrote: ... would give you the prefix string for your filename. ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)