From 92626f43af0637b37e3427b1b89b0e2c5c6027ac Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Mon, 1 May 2006 21:17:53 +0000 Subject: [PATCH] Added getDayOfWeek function which returns the numeric day of the week (1=Monday, 2=Tuesday, etc) --- lib/WebGUI/Session/DateTime.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm index 50563d0de..12c647f4e 100644 --- a/lib/WebGUI/Session/DateTime.pm +++ b/lib/WebGUI/Session/DateTime.pm @@ -357,6 +357,26 @@ sub getDayName { } } +#------------------------------------------------------------------- + +=head2 getDayOfWeek ( epoch) { + +Returns the position (1 - 7) of the day of the week of the epoch passed in. 1 is Monday, 2 is Tuesday, etc + +=head3 epoch + +An epoch date. + +=cut + +sub getDayOfWeek { + my $self = shift; + my $dt = DateTime->from_epoch( epoch => shift ); + $dt->set_time_zone($self->session->user->profileField("timeZone")|| "America/Chicago"); # assign the user's timezone + return $dt->day_of_week; +} + + #------------------------------------------------------------------- =head2 getDaysInMonth ( epoch )