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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sun Feb 9 16:15:51 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.2: +5 -2 lines
+ minor update regarding module namespace refactoring

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

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