diff options
author | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-11 23:48:39 +0000 |
---|---|---|
committer | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-11 23:48:39 +0000 |
commit | b1aaa3b6ca8894ac0422fb3aeadded29c2b83972 (patch) | |
tree | 7689417eb311569ffe966c5f60aeb7a8e9ff2035 /functions/init/date_range.php | |
parent | b8fa9f6a3a0d0bad52babec3573899ba37873477 (diff) | |
download | phpicalendar-b1aaa3b6ca8894ac0422fb3aeadded29c2b83972.tar.gz phpicalendar-b1aaa3b6ca8894ac0422fb3aeadded29c2b83972.tar.bz2 phpicalendar-b1aaa3b6ca8894ac0422fb3aeadded29c2b83972.zip |
add new files
Diffstat (limited to 'functions/init/date_range.php')
-rw-r--r-- | functions/init/date_range.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/functions/init/date_range.php b/functions/init/date_range.php new file mode 100644 index 0000000..565d0d1 --- /dev/null +++ b/functions/init/date_range.php @@ -0,0 +1,39 @@ +<?php +if (!isset($getdate)) { + if (isset($_GET['getdate']) && ($_GET['getdate'] !== '')) { + $getdate = $_GET['getdate']; + } else { + $getdate = date('Ymd', time() + $second_offset); + } +} + +preg_match ("/([0-9]{4})([0-9]{2})([0-9]{2})/", $getdate, $day_array2); +$this_day = $day_array2[3]; +$this_month = $day_array2[2]; +$this_year = $day_array2[1]; + +# set bounds on master_array +# mktime int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] ) +$start_month = $this_month - 1; +$start_year = $this_year; +$end_month = $this_month + 1; +$end_year = $this_year; +if ($this_month == 1){ + $start_month = 12; + $start_year--; +} +if ($this_month == 12){ + $end_month = 1; + $end_year++; +} +switch ($current_view){ + case 'month': + case 'week': + case 'day': + $mArray_begin = mktime (0,0,0,$start_month,21,($start_year)); + $mArray_end = mktime (0,0,0,$end_month,12,($end_year)); + break; + default: + $mArray_begin = mktime (0,0,0,12,21,($this_year - 1)); + $mArray_end = mktime (0,0,0,1,12,($this_year + 1)); +} |