/[cvs]/nfo/perl/libs/Date/Merge.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Date/Merge.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Dec 22 14:15:59 2002 UTC (21 years, 5 months ago) by joko
Branch: MAIN
+ initial check-in

1 joko 1.1 ## ------------------------------------------------------------------------
2     ## $Id$
3     ## ------------------------------------------------------------------------
4     ## $Log$
5     ## ------------------------------------------------------------------------
6    
7    
8     package Date::Merge;
9    
10     use strict;
11     use warnings;
12    
13     require Exporter;
14     our @ISA = qw( Exporter );
15     our @EXPORT_OK = qw(
16     mergeDayAndTime
17     );
18    
19    
20     use Date::Manip;
21     use libp qw( today );
22    
23    
24     sub mergeDayAndTime {
25    
26     my $day = shift;
27     my $time = shift;
28    
29     my $date_day_raw = $day;
30     my $date_time_raw = $time;
31    
32     # TODO: abstract this out (to a helper function) somehow
33     # take care not to exclude/export/refactor _this_ type of helper function to nirvana
34     # remember just _everything_ out of this scope is nirvana, so - right said - take care to stay in scope ...
35     # ... else this compartment would theoretically break, but may still work in real use under some "easy" circumstances
36     # (e.g. no other containerships, no parallelity, anything may/might happen)
37     # REVIEW: what about re-entrancy of _this_ type of helper functions/methods?
38    
39     $date_day_raw =~ s/[^\d|-]//g;
40     my $date_day = ParseDate($date_day_raw);
41    
42     # $date_time (just the time!) will get auto-converted to a datetime from today, so ....
43     my $date_time = ParseDate($date_time_raw);
44    
45     # ... we should calculate the delta to get the real time-shift to continue further processing with
46     my $date_time_delta = DateCalc(ParseDate(today()), '-' . $date_time);
47    
48     # add the delta to the 'date-day' parsed above to calculate the complete event-date ('endtime' in this case)
49     my $date_complete = DateCalc($date_day, $date_time_delta);
50    
51     # reformat the complete date to be a full compliant database-date
52     my $date_full = UnixDate($date_complete, '%Y-%m-%d %H:%M:%S');
53    
54     return $date_full;
55    
56     }
57    
58     1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed