cvs: smarty / NEWS /libs/plugins function.html_select_date.php
"Monte Ohrt" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmohrt1093009726@cvsserver> |
mohrt Fri Aug 20 09:48:46 2004 EDT
Modified files:
/smarty NEWS
/smarty/libs/plugins function.html_select_date.php
Log:
make time param work with negative timestamps, force year range to include
given date unless explicitly set
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.467&r2=1.468&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.467 smarty/NEWS:1.468
--- smarty/NEWS:1.467 Thu Aug 19 17:02:24 2004
+++ smarty/NEWS Fri Aug 20 09:48:46 2004
@@ -1,3 +1,6 @@
+ - make html_select_date work with negative timestamps, also
+ force year range to include given date unless explicitly
+ set (Garo, Monte)
- fix bug with fetch, passing user/pass in url did not work
(Monte)
- fix occasional wrong error messages on mismatched tags when
http://cvs.php.net/diff.php/smarty/libs/plugins/function.html_select_date.php?r1=1.25&r2=1.26&ty=u
Index: smarty/libs/plugins/function.html_select_date.php
diff -u smarty/libs/plugins/function.html_select_date.php:1.25 smarty/libs/plugins/function.html_select_date.php:1.26
--- smarty/libs/plugins/function.html_select_date.php:1.25 Fri Jul 23 11:34:53 2004
+++ smarty/libs/plugins/function.html_select_date.php Fri Aug 20 09:48:46 2004
@@ -122,6 +122,10 @@
}
}
+ if(preg_match('!^-\d+$!',$time)) {
+ // negative timestamp, use date()
+ $time = date('Y-m-d',$time);
+ }
// If $time is not in format yyyy-mm-dd
if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
// then $time is empty or unix timestamp or mysql timestamp
@@ -131,7 +135,7 @@
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
-
+
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
@@ -146,6 +150,14 @@
} else {
$start_year = strftime('%Y') - $match[2];
}
+ }
+ if($start_year > $time[0] && !isset($params['start_year'])) {
+ // force start year to include given date if not explicitly set
+ $start_year = $time[0];
+ }
+ if($end_year < $time[0] && !isset($params['end_year'])) {
+ // force end year to include given date if not explicitly set
+ $end_year = $time[0];
}
$field_order = strtoupper($field_order);
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php