summaryrefslogtreecommitdiff
path: root/adodb-time.inc.php
diff options
context:
space:
mode:
authorMark Newnham <mark@newnhams.com>2016-04-13 17:31:08 -0600
committerDamien Regad <dregad@mantisbt.org>2016-04-27 19:46:25 +0200
commita4c04ed9002842ce430ccff9bc9bcc402524da32 (patch)
treee2cdacac2da4b814a1c3acc366a709763966088b /adodb-time.inc.php
parent54dce6ab773d87aa62c931f7b52a7f94eac6f4ad (diff)
downloadadodb-a4c04ed9002842ce430ccff9bc9bcc402524da32.tar.gz
adodb-a4c04ed9002842ce430ccff9bc9bcc402524da32.tar.bz2
adodb-a4c04ed9002842ce430ccff9bc9bcc402524da32.zip
Add week of year support in date library
The ADOdb date/time library did not include support for the time format 'W' which returns the week of the year (1-52) that the provided date falls into. This format is supported by the standard PHP library, which means that if the provided date falls outside the 32-bit date range where adodb hands off data calculations to the standard gmdate for performance reasons, then the value is not calculated. 'W' is one of the standard identifiers used by sqlDate(), and adodb_date is used by sqlite to perform date calculations. Fixes #223
Diffstat (limited to 'adodb-time.inc.php')
-rw-r--r--adodb-time.inc.php3
1 files changed, 3 insertions, 0 deletions
diff --git a/adodb-time.inc.php b/adodb-time.inc.php
index e5caa2b3..cc4415f2 100644
--- a/adodb-time.inc.php
+++ b/adodb-time.inc.php
@@ -1162,6 +1162,9 @@ static $jan1_1971;
case 't': $dates .= $arr['ndays']; break;
case 'z': $dates .= $arr['yday']; break;
case 'w': $dates .= adodb_dow($year,$month,$day); break;
+ case 'W':
+ $dates .= sprintf('%02d',ceil( $arr['yday'] / 7) - 1);
+ break;
case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
case 'j': $dates .= $day; break;