flowdy has asked for the wisdom of the Perl Monks concerning the following question:
In the test suite of my urgency-based ranking task & time management system some tests fail at days with 23 or 25 hours (i.e. days we have to set the clock because a DST period starts or ends), simply due to the fact that the expected test results are wrong for these days. I kind of cheated by adding to the test description "fails at DST border days", but, well, failing tests are failing tests hence expose non-perfection of the implementation, right?
So, I am looking for an official module that finds out if a given date is a day with <> 24 hours. Sure I could use my own function:
sub detect_dst_clockface_sector { my $t1 = Mktime(@_, 0, 0, 0); my $t2 = Mktime(Add_Delta_Days(@_, 1), 0, 0, 0); my $shift = 24 - ($t2 - $t1) / 3600; return if !$shift; my ($i, $it1, $it2) = 0; while ( $i < 24 ) { $it2 = $t1 + $i * 3600; $it1 = $it2 - 1; $_ = (localtime($_))[2] for $it1, $it2; last if $it2 == ($it1+$shift+1) % 24; } continue { $i++; } if ( $i < 24 ) { return $i, $shift; } else { die "Couldn't figure out position of $shift dst-affected hours +"; } }
in a subcomponent module of my project. But it is idiotic practice to calculate expected values with code to test, so I would rather use something external. Do you know something? Plus, I do not cling to the code above, it seems of poor performance this algorithm, so maybe I could get rid of it in favor of that module searched for alltogether?
Best regards,
flowdy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there an official DST border day detection module?
by RonW (Parson) on Oct 27, 2014 at 17:26 UTC | |
by flowdy (Scribe) on Oct 27, 2014 at 20:14 UTC | |
by RonW (Parson) on Oct 28, 2014 at 17:02 UTC | |
by flowdy (Scribe) on Oct 28, 2014 at 19:59 UTC | |
by RonW (Parson) on Oct 29, 2014 at 18:48 UTC | |
|
Re: Is there an official DST border day detection module? (localtime)
by tye (Sage) on Oct 27, 2014 at 20:38 UTC | |
by flowdy (Scribe) on Oct 28, 2014 at 10:17 UTC | |
by hippo (Archbishop) on Oct 28, 2014 at 11:08 UTC |