root/Date-Range-Birth/trunk/README

Revision 368 (checked in by miyagawa, 18 years ago)

0.02

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Date::Range::Birth - range of birthday for an age
3
4 SYNOPSIS
5       use Date::Range::Birth;
6
7       # birthday for those who are 24 years old now
8       my $range = Date::Range::Birth->new(24);
9
10       # birthday for those who are 24 years old in 2001-01-01
11       my $date   = Date::Simple->new(2001, 1, 1);
12       my $range2 = Date::Range::Birth->new(24, $date);
13
14       # birthday for those who are between 20 and 30 yeard old now
15       my $range3 = Date::Range::Birth->new([ 20, 30 ]);
16
17 DESCRIPTION
18     Date::Range::Birth is a subclass of Date::Range, which provides a way to
19     construct range of dates for birthday.
20
21 METHODS
22     new $range = Date::Range::Birth->new($age); $range = Date::Range::Birth-
23         >new($age, $date); $range = Date::Range::Birth->new([ $young, $old
24         ]); $range = Date::Range::Birth->new([ $young, $old ], $date);
25
26         returns Date::Range::Birth object for birthday of the age. If
27         `$date' (Date::Simple object) provided, returns range of birthday
28         for those who are `$age' years old in `$date'. Default is today
29         (now).
30
31         If the age is provided as array reference (like `[ $young, $old ]'),
32         returns range of birthday for those who are between `$young' -
33         `$old' years old. It may be handy for searching teenagers, etc.
34
35     Other methods are inherited from Date::Range. See the Date::Range
36     manpage for details.
37
38 EXAMPLE
39     Your customer database schema:
40
41       CREATE TABLE customer (
42           name     varchar(64) NOT NULL,
43           birthday date NOT NULL
44       );
45
46     What you should do is to select name and birthday of the customers who
47     are 2X years old (between 20 and 29).
48
49       use DBI;
50       use Date::Range::Birth;
51
52       my $dbh = DBI->connect( ... );
53       my $range = Date::Range::Birth->new([ 20, 29 ]);
54
55       my $sth = $dbh->prepare(<<'SQL')
56       SELECT name, birthday FROM customer WHERE birthday >= ? AND birthday <= ?
57       SQL
58
59       # Date::Simple overloads to 'yyyy-mm-dd'!
60       $sth->execute($range->start, $range->end);
61
62       while (my $data = $sth->fetchrow_arrayref) {
63           print "name: $data->[0] birthday: $data->[1]\n";
64       }
65       $dbh->disconnect;
66
67 AUTHOR
68     Original idea by ikechin <ikebe@cpan.org>
69
70     Code implemented by Tatsuhiko Miyagawa <miyagawa@bulknews.net>
71
72     This library is free software; you can redistribute it and/or modify it
73     under the same terms as Perl itself.
74
75 SEE ALSO
76     the Date::Range manpage, the Date::Simple manpage, the Date::Calc
77     manpage
78
Note: See TracBrowser for help on using the browser.