Permalink
Browse files

TimeDate patch

  • Loading branch information...
1 parent 7143962 commit 3ef0b2458bc1488f11968684135971616bd44eb9 @pudge pudge committed Aug 7, 2001
View
@@ -1501,7 +1501,7 @@ sub getPollQuestionList {
my $questions = $self->sqlSelectAll("qid, question, date",
"pollquestions order by date DESC LIMIT $time,20");
- formatDate($questions, 2, 2, '%F'); # '%A %B %E' || '%F'
+ formatDate($questions, 2, 2, '%A, %B %e, %Y'); # '%F'
return $questions;
}
@@ -2937,7 +2937,7 @@ EOT
while (my $data = $cursor->fetchrow_arrayref) {
formatDate([$data], 3, 3, '%A %B %d %I %M %p');
- formatDate([$data], 5, 5, '%Q');
+ formatDate([$data], 5, 5, '%Y%m%d'); # %Q
next if $form->{issue} && $data->[5] > $form->{issue};
push @stories, [@$data];
last if ++$count >= $limit;
@@ -3368,7 +3368,7 @@ sub autoUrl {
my $more = substr $user->{nickname}, 1;
$more =~ s/[a-z]//g;
$initials = uc($initials . $more);
- my($now) = timeCalc('epoch ' . time(), '%m/%d %H:%M %p %Z', 0);
+ my($now) = timeCalc(scalar localtime, '%m/%d %H:%M %p %Z', 0); # epoch time
# Assorted Automatic Autoreplacements for Convenience
s|<disclaimer:(.*)>|<B><A HREF="/about.shtml#disclaimer">disclaimer</A>:<A HREF="$user->{homepage}">$user->{nickname}</A> owns shares in $1</B>|ig;
@@ -3432,7 +3432,7 @@ sub getTime {
sub getDay {
# my($self) = @_;
# my($now) = $self->sqlSelect('to_days(now())');
- my $yesterday = timeCalc('epoch ' . time, '%Q');
+ my $yesterday = timeCalc(scalar localtime, '%Y%m%d'); # epoch time, %Q
return $yesterday;
}
View
@@ -34,6 +34,7 @@ you use most.
=cut
+BEGIN { $ENV{TZ} = 'GMT' }
use Slash;
use Slash::Display;
use Slash::Utility;
View
@@ -25,7 +25,9 @@ LONG DESCRIPTION.
=cut
use strict;
-use Date::Manip qw(DateCalc UnixDate Date_Init);
+use Date::Format qw(time2str);
+use Date::Parse qw(str2time);
+#use Date::Manip qw(DateCalc UnixDate Date_Init);
use Digest::MD5 'md5_hex';
use HTML::Entities;
use HTML::FormatText;
@@ -201,7 +203,7 @@ the default value of AS is "time".
=item FORMAT
-Optional Date::Manip format string.
+Optional Date::Format format string.
=back
@@ -291,18 +293,22 @@ sub timeCalc {
# find out the user's time based on personal offset
# in seconds
- $date = DateCalc($date, "$off_set SECONDS", \$err) if $off_set;
+# $date = DateCalc($date, "$off_set SECONDS", \$err) if $off_set;
+ $date = str2time($date) + $off_set;
# set user's language
my $lang = getCurrentStatic('datelang') || 'English';
- Date_Init("Language=$lang") if $lang && $lang ne 'English';
+# Date_Init("Language=$lang") if $lang && $lang ne 'English';
+ Date::Format->language($lang) if $lang && $lang ne 'English';
# convert the raw date to pretty formatted date
- $date = UnixDate($date, $format || $user->{'format'});
+# $date = UnixDate($date, $format || $user->{'format'});
+ $date = time2str($format || $user->{'format'}, $date);
# so we can handle database dates properly; maybe
# check database engine behavior?
- Date_Init("Language=English") if $lang && $lang ne 'English';
+# Date_Init('Language=English') if $lang && $lang ne 'English';
+ Date::Format->language('English') if $lang && $lang ne 'English';
# return the new pretty date
return $date;
@@ -25,7 +25,7 @@ LONG DESCRIPTION.
=cut
use strict;
-use Date::Manip qw(ParseDate UnixDate);
+# use Date::Manip qw(ParseDate UnixDate);
use Slash::Display;
use Slash::Utility::Environment;
@@ -510,14 +510,15 @@ sub currentAdminUsers {
my $constants = getCurrentStatic();
my $user = getCurrentUser();
- my $now = UnixDate(ParseDate($slashdb->getTime()), "%s");
+# my $now = UnixDate(ParseDate($slashdb->getTime()), "%s");
+ my $now = timeCalc($slashdb->getTime(), "%s", 0);
my $aids = $slashdb->currentAdmin();
for my $data (@$aids) {
my($usernick, $usertime, $lasttitle) = @$data;
if ($usernick eq $user->{nickname}) {
$usertime = "-";
} else {
- $usertime = $now - UnixDate(ParseDate($usertime), "%s");
+ $usertime = $now - timeCalc($usertime, "%s", 0); # UnixDate(ParseDate($usertime), "%s");
if ($usertime <= 99) {
$usertime .= "s";
} elsif ($usertime <= 3600) {
@@ -1141,7 +1141,7 @@ sub prepareUser {
# This is here so when user selects "6 ish" it
# "posted by xxx around 6 ish" instead of "on 6 ish"
- if ($user->{'format'} eq '%i ish') {
+ if ($user->{'format'} eq '%l ish') { # %i
$user->{aton} = 'around'; # getData('atonish');
} else {
$user->{aton} = 'on'; # getData('aton');
View
@@ -24,7 +24,7 @@ Slash::XML aids in creating XML. Right now, only RSS is supported.
=cut
use strict;
-use Date::Manip;
+# use Date::Manip;
use Time::Local;
use Slash;
use Slash::Utility;
@@ -135,7 +135,7 @@ Return a standard ISO 8601 time string.
=item TIME
-Some sort of string in GMT that can be parsed by Date::Manip.
+Some sort of string in GMT that can be parsed by Date::Parse.
If no TIME given, uses current time.
=back
@@ -144,10 +144,6 @@ If no TIME given, uses current time.
The time string.
-=item Dependencies
-
-Date::Manip.
-
=back
=cut
@@ -158,14 +154,14 @@ sub date2iso8601 {
$time .= ' GMT' unless $time =~ / GMT$/;
} else { # get current seconds
my $t = defined $time ? 0 : time();
- $time = "epoch $t";
+ $time = scalar localtime($t);
}
# calculate timezone differential from GMT
my $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;
($diff = sprintf '%+0.4d', $diff) =~ s/(\d{2})$/:$1/;
- return scalar UnixDate($time, "%Y-%m-%dT%H:%M:%S$diff");
+ return scalar timeCalc($time, "%Y-%m-%dT%H:%M:%S$diff", 0);
}
#========================================================================
View
@@ -5,7 +5,7 @@
# $Id$
use strict;
-use Date::Manip;
+# use Date::Manip;
use Image::Size;
use POSIX;
@@ -138,13 +138,18 @@ sub main {
undef $form->{title} if ($form->{sid} && $form->{op} eq 'edit');
}
- # "backSlash" needs to be in a template or something -- pudge
- my $gmt_now_secs = UnixDate(ParseDate($slashdb->getTime()), "%s");
- my $gmt_ts = UnixDate("epoch $gmt_now_secs", "%T");
- my $local_ts = UnixDate("epoch ".($gmt_now_secs + $user->{off_set}), "%T");
+# my $gmt_now_secs = UnixDate(ParseDate($slashdb->getTime()), "%s");
+# my $gmt_ts = UnixDate("epoch $gmt_now_secs", "%T");
+# my $local_ts = UnixDate("epoch ".($gmt_now_secs + $user->{off_set}), "%T");
+
+ my $db_time = $slashdb->getTime();
+ my $gmt_ts = timeCalc($db_time, "%T", 0);
+ my $local_ts = timeCalc($db_time, "%T");
+
my $time_remark = (length $tbtitle > 10)
? " $gmt_ts"
: " $local_ts $user->{tzcode} = $gmt_ts GMT";
+ # "backSlash" needs to be in a template or something -- pudge
header("backSlash$time_remark$tbtitle", 'admin');
# Admin Menu
View
@@ -12,7 +12,7 @@
use sigtrap;
use strict;
use Carp;
-use Date::Manip;
+# use Date::Manip;
use File::Basename;
use File::Path;
use LWP::UserAgent;
@@ -175,7 +175,8 @@ EOT
}
sub db_time {
- return UnixDate(ParseDate($slashdb->getTime()), "%s");
+# return UnixDate(ParseDate($slashdb->getTime()), "%s");
+ return timeCalc($slashdb->getTime(), "%s", 0);
}
# NOTE: This logic is busted. What we really need to do is keep a list
View
@@ -110,10 +110,13 @@ INSERT INTO dateformats (id, format, description) VALUES (7,'%m-%d-%y %k:%M','3-
INSERT INTO dateformats (id, format, description) VALUES (8,'%d-%m-%y %k:%M','21-3-99 23:00');
INSERT INTO dateformats (id, format, description) VALUES (9,'%m-%d-%y %I:%M %p','3-21-99 10:00 AM');
INSERT INTO dateformats (id, format, description) VALUES (15,'%d/%m/%y %k:%M','21/03/99 23:00');
-INSERT INTO dateformats (id, format, description) VALUES (10,'%I:%M %p %B %E, %Y','10:00 AM March 21st, 1999');
-INSERT INTO dateformats (id, format, description) VALUES (11,'%k:%M %E %B, %Y','23:00 21st March, 1999');
+#INSERT INTO dateformats (id, format, description) VALUES (10,'%I:%M %p %B %E, %Y','10:00 AM March 21st, 1999');
+INSERT INTO dateformats (id, format, description) VALUES (10,'%I:%M %p %B %o, %Y','10:00 AM March 21st, 1999');
+#INSERT INTO dateformats (id, format, description) VALUES (11,'%k:%M %E %B, %Y','23:00 21st March, 1999');
+INSERT INTO dateformats (id, format, description) VALUES (11,'%k:%M %o %B, %Y','23:00 21st March, 1999');
INSERT INTO dateformats (id, format, description) VALUES (12,'%a %b %d, \'%y %I:%M %p','Sun Mar 21, \'99 10:00 AM');
-INSERT INTO dateformats (id, format, description) VALUES (13,'%i ish','6 ish');
+#INSERT INTO dateformats (id, format, description) VALUES (13,'%i ish','6 ish');
+INSERT INTO dateformats (id, format, description) VALUES (13,'%l ish','6 ish');
INSERT INTO dateformats (id, format, description) VALUES (14,'%y-%m-%d %k:%M','99-03-19 14:14');
INSERT INTO dateformats (id, format, description) VALUES (16,'%a %d %b %I:%M%p','Sun 21 Mar 10:00AM');
INSERT INTO dateformats (id, format, description) VALUES (17,'%Y.%m.%d %k:%M','1999.03.19 14:14');
@@ -5,7 +5,7 @@
# $Id$
use strict;
-use Date::Manip;
+#use Date::Manip; # is this needed? -- pudge
use HTML::Entities;
use Slash;
use Slash::Display;
@@ -5,7 +5,7 @@
# $Id$
use strict;
-use Date::Manip;
+use Date::Manip qw(UnixDate DateCalc);
use Digest::MD5 'md5_hex';
use Slash;
use Slash::Display;
@@ -595,9 +595,9 @@ sub showInfo {
$lastgranted = $slashdb->getUser($uid, 'lastgranted');
if ($lastgranted) {
$lastgranted = timeCalc(
- DateCalc($lastgranted,
- '+ ' . ($constants->{stir}+1) . ' days'),
- '%Y-%m-%d'
+ UnixDate(DateCalc($lastgranted,
+ '+ ' . ($constants->{stir}+1) . ' days'
+ ), "%C"), '%Y-%m-%d'
);
}
}
@@ -43,8 +43,8 @@ __template__
[% UNLESS is_anon %]
<A HREF="[% constants.rootdir %]/users.pl?op=userinfo&amp;nick=[% FILTER fixparam; nickname; END %]">User #[% uid %] Info</A>
[% IF homepage && homepage.length > 8 %] | <A HREF="[% homepage %]">[% homepage %]</A>[% END %]
-[% journal_date = Slash.timeCalc(journal_last_entry_date); IF journal_date %] | Last Journal:
-<A HREF="[% constants.rootdir %]/journal.pl?op=display&amp;uid=[% uid %]">[% journal_date %]</A>
+[% IF journal_last_entry_date.search('[1-9]') %] | Last Journal:
+<A HREF="[% constants.rootdir %]/journal.pl?op=display&amp;uid=[% uid %]">[% Slash.timeCalc(journal_last_entry_date) %]</A>
[% END %]
[% END %]
</FONT>
@@ -57,9 +57,9 @@ before you do any moderation.<BR><P>
<A HREF="[% useredit.homepage %]">[% useredit.homepage %]</A><BR>
[% END; IF useredit.fakeemail %]
<A HREF="mailto:[% useredit.fakeemail %]">[% useredit.fakeemail %]</A><BR>
-[% END; journal_date = Slash.timeCalc(useredit.journal_last_entry_date); IF journal_date %]
+[% END; IF useredit.journal_last_entry_date.search('[1-9]') %]
<A HREF="[% constants.rootdir %]/journal.pl?op=display&amp;uid=[% useredit.uid %]">
-Last Journal Entry was [% journal_date %]</A>
+Last Journal Entry was [% Slash.timeCalc(useredit.journal_last_entry_date) %]</A>
[ <A HREF="[% constants.rootdir %]/journal.pl?op=list&amp;uid=[% useredit.uid %]">List</A> ]
<BR>
[% END %]
View
@@ -78,6 +78,7 @@ my %data = (
)],
'Slash::Utility::Display' => [qw(
Slash::Display
+ Slash::Utility::Data
Slash::Utility::Environment
)],
'Slash::Utility::Environment' => [qw(
View
@@ -8,7 +8,7 @@ use sigtrap;
use strict;
use Carp;
use Getopt::Std;
-use Date::Manip;
+# use Date::Manip; # is this needed? -- pudge
use File::Basename;
use File::Path;
use LWP::UserAgent;
@@ -174,7 +174,8 @@ sub main {
exit 0;
};
- srand(time() ^ ($$+($$<<15)));
+# srand is almost always superfluous in perl 5.004 and later -- pudge
+# srand(time() ^ ($$+($$<<15)));
my $subref = get_task_subref;
slashdLog("$task_name begin");

0 comments on commit 3ef0b24

Please sign in to comment.