|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
built-in gmtime() returning one month off?by snafu (Chaplain) |
| on Jun 18, 2002 at 15:00 UTC ( [id://175460]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.snafu has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write a program that stages files to later archive based off of either dates embedded in the filenames or if those don't exist then from the date of the mtime on the filesystem for each file.
Ok, so, that being said, I need the date to be as accurate as possible. However, after some tests I am finding that the mtime returned from stat() and then being converted to human readable format via Perl's built-in gmtime() that for some reason the month returned is one month off. I find it more difficult to believe that there is something wrong with Perl versus something wrong with what I am doing. Please check my work and see if I am off somewhere. First, I touch a file so I get the desired mtime that I am looking for. I check the mtime using a utility I wrote called macls. Here is the output...
Note the strange and abnormal dates how they jump around and stuff =P jk. Anyway, so we know the dates are on the file system the way I want them. Oh, also note that the time stamp I used for the touch command is in the filename so I can reference it should the mtime get whacked in the moving of the files from place to place on the fs. One thing I just noticed is the actual time I specified for the touch command is off by one hour on the file system. Very interesting.
Ok. Now, I now do the following: For everyone who doesn't know, the first number is the day, the second number is the month and the third number is the year - 1900. Everything is fine except the month value. Its off by a month. What am I overlooking?
_
_
_
_
_
_
_
_
_
_
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||