root/Dunce-time/trunk/README

Revision 71 (checked in by miyagawa, 19 years ago)

added Dunce::time

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Dunce::time - Protects against sloppy use of time.
3
4 SYNOPSIS
5       use Dunce::time;
6
7       my $this = time;
8       my $that = time;
9
10       my @sorted = sort $this, $that; # die with an error
11       my @numerically_sorted = sort { $a <=> $b } $this, $that; # OK
12
13 DESCRIPTION
14     On Sun Sep 9 01:46:40 2001 GMT, time_t (UNIX epoch) reaches 10 digits.
15     Sorting time()'s as strings will cause unexpected result after that.
16
17     When Dunce::time is used, it provides special version of time() which
18     will die with a message when compared as strings.
19
20 USAGE
21     Just use the module. If it detects a problem, it will cause your program
22     to abort with an error. If you don't like this behaviour, you can use
23     the module with tags like ":WARN" or ":FIX".
24
25       use Dunce::time qw(:WARN);
26
27     With ":WARN" tag, it will just warn instead of dying.
28
29       use Dunce::time qw(:FIX);
30       @sorted = sort @time; # acts like sort { $a <=> $b } @time;
31
32     With ":FIX" tag, it will warn and change the comparison behaviour so
33     that it acts like compared numerically.
34
35 CAVEATS
36     You store the variables into storage (like DBMs, databases), retrieve
37     them from storage, and compare them as strings ... this can't detect in
38     such a case.
39
40 AUTHOR
41     Tatsuhiko Miyagawa <miyagawa@bulknews.net>
42
43     This library is free software; you can redistribute it and/or modify it
44     under the same terms as Perl itself.
45
46 SEE ALSO
47     the Dunce::time::Zerofill manpage, the D::oh::Year manpage, the overload
48     manpage, the perl manpage
49
Note: See TracBrowser for help on using the browser.