Date and time functions are now more accurate. And events calendar allows for weeks starting with monday rather than sunday.
This commit is contained in:
parent
948667beaf
commit
fa1f4145c5
4 changed files with 44 additions and 34 deletions
|
|
@ -29,7 +29,7 @@ Contributing Translators.............Andreas Ljunggren
|
||||||
|
|
||||||
Perl.................................Larry Wall / O'Reilly
|
Perl.................................Larry Wall / O'Reilly
|
||||||
|
|
||||||
RSSLite..............................Jerrad Pierce
|
XML::RSSLite.........................Jerrad Pierce
|
||||||
Scott Thomason
|
Scott Thomason
|
||||||
|
|
||||||
IE Rich Edit.........................Brattli
|
IE Rich Edit.........................Brattli
|
||||||
|
|
@ -38,4 +38,7 @@ Data::Config.........................S
|
||||||
|
|
||||||
HTML::TagFilter......................William Ross
|
HTML::TagFilter......................William Ross
|
||||||
|
|
||||||
|
HTML::CalendarMonthSimple............Gregor Mosheh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,22 @@
|
||||||
insert into webguiVersion values ('4.5.0','upgrade',unix_timestamp());
|
insert into webguiVersion values ('4.5.0','upgrade',unix_timestamp());
|
||||||
insert into international values (72,'Poll',1,'Randomize answers?');
|
insert into international values (72,'Poll',1,'Randomize answers?');
|
||||||
alter table Poll add column randomizeAnswers int not null default 0;
|
alter table Poll add column randomizeAnswers int not null default 0;
|
||||||
|
insert into userProfileField values ('firstDayOfWeek','WebGUI::International::get(699,"WebGUI");',1,0,'select','{0=>WebGUI::International::get(27,"WebGUI"),1=>WebGUI::International::get(28,"WebGUI")}','[0]',2,4,1);
|
||||||
|
update userProfileField set sequenceNumber=sequenceNumber+1 where profileCategoryId=4 and sequenceNumber>=2;
|
||||||
|
insert into international values (699,"WebGUI",1,"First Day Of Week");
|
||||||
|
update international set message='Calendar Month' where internationalId=18 and namespace='EventsCalendar';
|
||||||
|
insert into international values (74,'EventsCalendar',1,'Calendar Month (Small)');
|
||||||
|
update EventsCalendar set calendarLayout='calendarMonth' where calendarLayout='calendar';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,11 @@ package WebGUI::DateTime;
|
||||||
use Date::Calc;
|
use Date::Calc;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use strict;
|
use strict;
|
||||||
use Time::Local;
|
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(&addToTime &addToDate &epochToHuman &epochToSet &humanToEpoch &setToEpoch &monthStartEnd);
|
our @EXPORT = qw(&localtime &time &addToTime &addToDate &epochToHuman &epochToSet &humanToEpoch &setToEpoch &monthStartEnd);
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub _getMonth {
|
sub _getMonth {
|
||||||
|
|
@ -74,25 +73,6 @@ sub addToTime {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub epochToHuman {
|
sub epochToHuman {
|
||||||
my ($offset, $temp, $hour12, $value, $output, @date, %weekday, %month);
|
my ($offset, $temp, $hour12, $value, $output, @date, %weekday, %month);
|
||||||
|
|
||||||
# 0 1 2 3 4 5 6 7 8
|
|
||||||
# $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
|
||||||
# localtime(time);
|
|
||||||
#
|
|
||||||
# All list elements are numeric, and come straight
|
|
||||||
# out of the C `struct tm'. $sec, $min, and $hour
|
|
||||||
# are the seconds, minutes, and hours of the
|
|
||||||
# specified time. $mday is the day of the month,
|
|
||||||
# and $mon is the month itself, in the range `0..11'
|
|
||||||
# with 0 indicating January and 11 indicating
|
|
||||||
# December. $year is the number of years since
|
|
||||||
# 1900. That is, $year is `123' in year 2023.
|
|
||||||
# $wday is the day of the week, with 0 indicating
|
|
||||||
# Sunday and 3 indicating Wednesday. $yday is the
|
|
||||||
# day of the year, in the range `1..365' (or
|
|
||||||
# `1..366' in leap years.) $isdst is true if the
|
|
||||||
# specified time occurs during daylight savings
|
|
||||||
# time, false otherwise.
|
|
||||||
$offset = $session{user}{timeOffset} || 0;
|
$offset = $session{user}{timeOffset} || 0;
|
||||||
$offset = $offset*3600;
|
$offset = $offset*3600;
|
||||||
$temp = $_[0] || time();
|
$temp = $_[0] || time();
|
||||||
|
|
@ -171,17 +151,22 @@ sub humanToEpoch {
|
||||||
my (@temp, $dateString, $timeString, $output, @date);
|
my (@temp, $dateString, $timeString, $output, @date);
|
||||||
($dateString,$timeString) = split(/ /,$_[0]);
|
($dateString,$timeString) = split(/ /,$_[0]);
|
||||||
@temp = split(/-/,$dateString);
|
@temp = split(/-/,$dateString);
|
||||||
$date[5] = $temp[0]-1900;
|
$date[0] = int($temp[0]);
|
||||||
$date[4] = $temp[1]-1;
|
$date[1] = int($temp[1]);
|
||||||
$date[3] = $temp[2]+0;
|
$date[2] = int($temp[2]);
|
||||||
@temp = split(/:/,$timeString);
|
@temp = split(/:/,$timeString);
|
||||||
$date[2] = $temp[0]+0;
|
$date[3] = int($temp[0]);
|
||||||
$date[1] = $temp[1]+0;
|
$date[4] = int($temp[1]);
|
||||||
$date[0] = $temp[2]+0;
|
$date[5] = int($temp[2]);
|
||||||
$output = timelocal(@date);
|
$output = Date::Calc::Date_to_Time(@date);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub localtime {
|
||||||
|
return Date::Calc::Localtime($_[0]);
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub monthStartEnd {
|
sub monthStartEnd {
|
||||||
my ($year,$month,$day, $hour,$min,$sec, $start, $end);
|
my ($year,$month,$day, $hour,$min,$sec, $start, $end);
|
||||||
|
|
@ -199,7 +184,7 @@ sub setToEpoch {
|
||||||
if (int($year) < 2038 && int($year) > 1900) {
|
if (int($year) < 2038 && int($year) > 1900) {
|
||||||
$year = int($year);
|
$year = int($year);
|
||||||
} else {
|
} else {
|
||||||
$year = $date[5]+1900;
|
$year = $date[5];
|
||||||
}
|
}
|
||||||
if (int($month) < 13 && int($month) > 0) {
|
if (int($month) < 13 && int($month) > 0) {
|
||||||
$month = int($month);
|
$month = int($month);
|
||||||
|
|
@ -211,9 +196,12 @@ sub setToEpoch {
|
||||||
} else {
|
} else {
|
||||||
$day = $date[3];
|
$day = $date[3];
|
||||||
}
|
}
|
||||||
return humanToEpoch($year.'-'.$month.'-'.$day.' 00:00:00');
|
return Date::Calc::Date_to_Time($year,$month,$day,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub time {
|
||||||
|
return Date::Calc::Mktime(Date::Calc::Today_and_Now());
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ sub _calendarLayout {
|
||||||
$calendar->cellclass("tableData");
|
$calendar->cellclass("tableData");
|
||||||
$calendar->todaycellclass("tableHeader");
|
$calendar->todaycellclass("tableHeader");
|
||||||
$calendar->headerclass("tableHeader");
|
$calendar->headerclass("tableHeader");
|
||||||
|
$calendar->mondayisfirstday($session{user}{firstDayOfWeek});
|
||||||
($start,$end) = monthStartEnd($_[1]);
|
($start,$end) = monthStartEnd($_[1]);
|
||||||
$sth = WebGUI::SQL->read("select * from EventsCalendar_event where wobjectId=".$_[0]->get("wobjectId")." order by startDate,endDate");
|
$sth = WebGUI::SQL->read("select * from EventsCalendar_event where wobjectId=".$_[0]->get("wobjectId")." order by startDate,endDate");
|
||||||
while (%event = $sth->hash) {
|
while (%event = $sth->hash) {
|
||||||
|
|
@ -174,7 +175,8 @@ sub www_edit {
|
||||||
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
|
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
|
||||||
$f = WebGUI::HTMLForm->new;
|
$f = WebGUI::HTMLForm->new;
|
||||||
%hash = (list => WebGUI::International::get(17,$namespace),
|
%hash = (list => WebGUI::International::get(17,$namespace),
|
||||||
calendar => WebGUI::International::get(18,$namespace));
|
calendarMonth => WebGUI::International::get(18,$namespace),
|
||||||
|
calendarMonthSmall => WebGUI::International::get(74,$namespace);
|
||||||
$f->select("calendarLayout",\%hash,WebGUI::International::get(16,$namespace),[$_[0]->get("calendarLayout")]);
|
$f->select("calendarLayout",\%hash,WebGUI::International::get(16,$namespace),[$_[0]->get("calendarLayout")]);
|
||||||
$f->integer("paginateAfter",WebGUI::International::get(19,$namespace),$paginateAfter);
|
$f->integer("paginateAfter",WebGUI::International::get(19,$namespace),$paginateAfter);
|
||||||
$f->yesNo("proceed",WebGUI::International::get(21,$namespace),$proceed);
|
$f->yesNo("proceed",WebGUI::International::get(21,$namespace),$proceed);
|
||||||
|
|
@ -321,7 +323,7 @@ sub www_view {
|
||||||
$minDate = time();
|
$minDate = time();
|
||||||
$maxDate = time()+86400;
|
$maxDate = time()+86400;
|
||||||
}
|
}
|
||||||
if ($_[0]->get("calendarLayout") eq "calendar") {
|
if ($_[0]->get("calendarLayout") eq "calendarMonth") {
|
||||||
$nextDate = $minDate;
|
$nextDate = $minDate;
|
||||||
while ($nextDate <= $maxDate) {
|
while ($nextDate <= $maxDate) {
|
||||||
$row[$i] = _calendarLayout($_[0],$nextDate);
|
$row[$i] = _calendarLayout($_[0],$nextDate);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue