/[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.2 - (show annotations)
Mon Dec 23 13:44:53 2002 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.1: +19 -2 lines
+ sub stripDayName

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

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