| 1 | |||
| 2 | package DBIx::XML::DataLoader::Date; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | ### this is a simple module that has four available sub routine | ||
| 8 | ### | ||
| 9 | ### the sub "now" takes no arguments and returns the date as | ||
| 10 | ### translated from localtime | ||
| 11 | ### | ||
| 12 | ### the sub "nowTime" takes no argument and returns the current time | ||
| 13 | ### | ||
| 14 | ### the sub "nowDate" takes no argument and returns the current date | ||
| 15 | ### | ||
| 16 | ### the sub "nowDay" takes no argument and returns the current day of week | ||
| 17 | ### | ||
| 18 | |||
| 19 | |||
| 20 | ########### | ||
| 21 | sub new{ | ||
| 22 | ######## | ||
| 23 | |||
| 24 | my $self = shift; | ||
| 25 | bless \$self; | ||
| 26 | |||
| 27 | ####### | ||
| 28 | } # end sub new | ||
| 29 | ################ | ||
| 30 | |||
| 31 | ############### | ||
| 32 | sub now{ | ||
| 33 | ######## | ||
| 34 | |||
| 35 | my @time=localtime; | ||
| 36 | $time[1]=~ s/^\d$/0$&/; | ||
| 37 | $time[2]=~ s/^\d$/0$&/; | ||
| 38 | $time[0]=~ s/^\d$/0$&/; | ||
| 39 | my $now= "Time ".$time[2].":".$time[1].":".$time[0]." Date ".($time[4]+1)."/".$time[3]."/".($time[5]+1900); | ||
| 40 | return $now; | ||
| 41 | |||
| 42 | ######## | ||
| 43 | }# end sub now | ||
| 44 | ################# | ||
| 45 | |||
| 46 | ################ | ||
| 47 | sub nowTime{ | ||
| 48 | ############ | ||
| 49 | my @time=localtime; | ||
| 50 | $time[1]=~ s/^\d$/0$&/; | ||
| 51 | $time[2]=~ s/^\d$/0$&/; | ||
| 52 | $time[0]=~ s/^\d$/0$&/; | ||
| 53 | my $now=$time[2].":".$time[1].":".$time[0]; | ||
| 54 | return $now; | ||
| 55 | |||
| 56 | ########### | ||
| 57 | } #end sub nowTime | ||
| 58 | ################### | ||
| 59 | |||
| 60 | ################## | ||
| 61 | sub nowDate{ | ||
| 62 | ############ | ||
| 63 | |||
| 64 | my @time=localtime; | ||
| 65 | $time[1]=~ s/^\d$/0$&/; | ||
| 66 | $time[2]=~ s/^\d$/0$&/; | ||
| 67 | $time[0]=~ s/^\d$/0$&/; | ||
| 68 | |||
| 69 | my $now=($time[4]+1)."/".$time[3]."/".($time[5]+1900); | ||
| 70 | |||
| 71 | return $now; | ||
| 72 | |||
| 73 | ########### | ||
| 74 | } # end sub nowDate | ||
| 75 | ################## | ||
| 76 | |||
| 77 | ################### | ||
| 78 | sub nowDay{ | ||
| 79 | ########### | ||
| 80 | |||
| 81 | my $now=('Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat')[(localtime)[6]]; | ||
| 82 | |||
| 83 | return $now; | ||
| 84 | |||
| 85 | ########### | ||
| 86 | } #end sub nowDay | ||
| 87 | ################## | ||
| 88 | |||
| 89 | |||
| 90 | 1; | ||
| 91 | |||
| 92 | |||
| 93 | __END__ |