aboutsummaryrefslogtreecommitdiffstats
path: root/functions/date_functions.php
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-09-30 12:09:17 +0000
committerjwangen <jwangen>2002-09-30 12:09:17 +0000
commitea76f46e8677d5d0d3fa5400fb1211d2df6071a6 (patch)
tree1b0483292aae547cf5c2a32d84c77de90952dfa0 /functions/date_functions.php
parent8973b748535409a51987c391c5c892c89d80269f (diff)
downloadphpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.tar.gz
phpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.tar.bz2
phpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.zip
added yearly recurrence support
merged allday events and regular recurring events, see dev-email list for details alldays.ics is a test file that just has allday events
Diffstat (limited to 'functions/date_functions.php')
-rw-r--r--functions/date_functions.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/functions/date_functions.php b/functions/date_functions.php
index 1b09b9d..f2e67d7 100644
--- a/functions/date_functions.php
+++ b/functions/date_functions.php
@@ -1 +1 @@
-<?php // date_functions.php // functions for returning or comparing dates // takes Apple's 2 character day format and makes it into 3 characters function two2threeCharDays($day) { if ($day == "SU") $day_longer = "sun"; elseif ($day == "MO") $day_longer = "mon"; elseif ($day == "TU") $day_longer = "tue"; elseif ($day == "WE") $day_longer = "wed"; elseif ($day == "TH") $day_longer = "thu"; elseif ($day == "FR") $day_longer = "fri"; elseif ($day == "SA") $day_longer = "sat"; return $day_longer; } // dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more // and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su") function dateOfWeek($Ymd, $day) { global $week_start_day; if (!$week_start_day) $week_start_day = "Sunday"; $timestamp = strtotime($Ymd); $num = date("w", strtotime($week_start_day)); $start_day_time = strtotime((date("w",$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); return date("Ymd",strtotime($day,$start_day_time)); } // function to compare to dates in Ymd and return the number of weeks // that differ between them. requires dateOfWeek() function weekCompare($now, $then) { global $week_start_day; $sun_now = dateOfWeek($now, $week_start_day); $sun_then = dateOfWeek($then, $week_start_day); $seconds_now = strtotime($sun_now); $seconds_then = strtotime($sun_then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); $diff_weeks = $diff_days/7; return $diff_weeks; } // function to compare to dates in Ymd and return the number of days // that differ between them. function dayCompare($now, $then) { $seconds_now = strtotime($now); $seconds_then = strtotime($then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); return $diff_days; } // function to compare to dates in Ymd and return the number of months // that differ between them. function monthCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; $diff_months = $date_now[2] - $date_then[2]; if ($date_now[2] < $date_then[2]) { $diff_years -= 1; $diff_months = ($diff_months + 12) % 12; } $diff_months = ($diff_years * 12) + $diff_months; return $diff_months; } ?> \ No newline at end of file
+<?php // date_functions.php // functions for returning or comparing dates // takes Apple's 2 character day format and makes it into 3 characters function two2threeCharDays($day) { if ($day == "SU") $day_longer = "sun"; elseif ($day == "MO") $day_longer = "mon"; elseif ($day == "TU") $day_longer = "tue"; elseif ($day == "WE") $day_longer = "wed"; elseif ($day == "TH") $day_longer = "thu"; elseif ($day == "FR") $day_longer = "fri"; elseif ($day == "SA") $day_longer = "sat"; return $day_longer; } // dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more // and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su") function dateOfWeek($Ymd, $day) { global $week_start_day; if (!$week_start_day) $week_start_day = "Sunday"; $timestamp = strtotime($Ymd); $num = date("w", strtotime($week_start_day)); $start_day_time = strtotime((date("w",$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); return date("Ymd",strtotime($day,$start_day_time)); } // function to compare to dates in Ymd and return the number of weeks // that differ between them. requires dateOfWeek() function weekCompare($now, $then) { global $week_start_day; $sun_now = dateOfWeek($now, $week_start_day); $sun_then = dateOfWeek($then, $week_start_day); $seconds_now = strtotime($sun_now); $seconds_then = strtotime($sun_then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); $diff_weeks = $diff_days/7; return $diff_weeks; } // function to compare to dates in Ymd and return the number of days // that differ between them. function dayCompare($now, $then) { $seconds_now = strtotime($now); $seconds_then = strtotime($then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); return $diff_days; } // function to compare to dates in Ymd and return the number of months // that differ between them. function monthCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; $diff_months = $date_now[2] - $date_then[2]; if ($date_now[2] < $date_then[2]) { $diff_years -= 1; $diff_months = ($diff_months + 12) % 12; } $diff_months = ($diff_years * 12) + $diff_months; return $diff_months; } function yearCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; return $diff_years; } ?> \ No newline at end of file

© 2014-2024 Faster IT GmbH | imprint | privacy policy