Hi
if I understand correctly Date::Calc module documentation, the following code should always print the same date.
It does not. The printed dates even change if I run the code more times...
Is there a mistake in my code, or it is a problem with Windows (Strawberry Perl)?
Thanks!
use strict;
use Date::Calc qw(Date_to_Time Time_to_Date);
my @current_date = (2023,5,17, 1,0,0);
for my $i (1..10) {
my $time = Date_to_Time(@current_date);
my @date = Time_to_Date([$time]);
print join(",",@date),"\n";
}
Result:
C:> perl date.pl
1970,6,10,23,54,16
1970,6,10,23,57,28
1970,6,11,0,0,40
1970,6,10,23,54,40
1970,6,11,0,0,16
1970,6,11,0,16,16
1970,6,10,23,55,4
1970,6,10,23,57,52
1970,6,10,23,59,52
1970,6,10,23,54,16
C:> perl date.pl
1971,4,5,20,27,4
1971,4,5,20,30,16
1971,4,5,20,33,28
1971,4,5,20,27,28
1971,4,5,20,33,4
1971,4,5,20,49,4
1971,4,5,20,27,52
1971,4,5,20,30,40
1971,4,5,20,32,40
1971,4,5,20,27,4
Code tags added by GrandFather
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.