summaryrefslogtreecommitdiffstats
path: root/whine.pl
diff options
context:
space:
mode:
Diffstat (limited to 'whine.pl')
-rwxr-xr-xwhine.pl8
1 files changed, 6 insertions, 2 deletions
diff --git a/whine.pl b/whine.pl
index 52fbe4e82..97378a178 100755
--- a/whine.pl
+++ b/whine.pl
@@ -118,12 +118,16 @@ if (open(NOMAIL, '<', "$datadir/nomail")) {
}
# get the current date and time from the database
-$sth = $dbh->prepare( 'SELECT DATE_FORMAT( NOW(), "%y,%m,%e,%w,%k,%i")');
+$sth = $dbh->prepare('SELECT ' . $dbh->sql_date_format('NOW()', '%y,%m,%d,%a,%H,%i'));
$sth->execute;
-my ($now_year, $now_month, $now_day, $now_weekday, $now_hour, $now_minute) =
+my ($now_year, $now_month, $now_day, $now_weekdayname, $now_hour, $now_minute) =
split(',', $sth->fetchrow_array);
$sth->finish;
+# As DBs have different days numbering, use day name and convert it
+# to the range 0-6
+my $now_weekday = index("SunMonTueWedThuFriSat", $now_weekdayname) / 3;
+
my @daysinmonth = qw(0 31 28 31 30 31 30 31 31 30 31 30 31);
# Alter February in case of a leap year. This simple way to do it only
# applies if you won't be looking at February of next year, which whining