← Back to team overview

anewt-developers team mailing list archive

[Branch ~uws/anewt/anewt.uws] Rev 1731: [core] Recognize (but ignore) SQL datetimes with a TZ

 

------------------------------------------------------------
revno: 1731
author: Sander van Schouwenburg <sander@xxxxxxxxxxxxx>
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt.uws
timestamp: Sun 2009-08-02 22:26:54 +0200
message:
  [core] Recognize (but ignore) SQL datetimes with a TZ
  
  AnewtDateTime::parse_string() will now parse (and ignore)
  datetime values a time zone specifier attached. These
  strings are returned for PostgreSQL's 'timestamptz' column
  type.
  
  Patch by Sander van Schouwenburg.
modified:
  core/datetime.lib.php


--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws

Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription.
=== modified file 'core/datetime.lib.php'
--- core/datetime.lib.php	2009-07-20 20:39:48 +0000
+++ core/datetime.lib.php	2009-08-02 20:26:54 +0000
@@ -43,7 +43,7 @@
 /** Regular expression for abbreviated month names */
 define('DATETIME_RE_MONTH_NAMES_ABBR',   '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dev)');
 /** Regular expression for timezones */
-define('DATETIME_RE_TIMEZONE',          '(GMT|[\+\-][012][0-9][03]0)');
+define('DATETIME_RE_TIMEZONE',          '(GMT|[\+\-][012][0-9](:?[03]0)?)');
 
 
 /**
@@ -294,9 +294,9 @@
 		/* Date and time */
 
 		// SQL92 DATETIME: 2005-10-31 12:00:00
-		$pattern = sprintf('/^(%s)-(%s)-(%s) (%s):(%s):(%s)(\.\d+)?$/', DATETIME_RE_YEAR,
+		$pattern = sprintf('/^(%s)-(%s)-(%s) (%s):(%s):(%s)(\.\d+)?(%s)?$/', DATETIME_RE_YEAR,
 				DATETIME_RE_MONTH, DATETIME_RE_DAY, DATETIME_RE_HOUR, DATETIME_RE_MINUTE,
-				DATETIME_RE_SECOND);
+				DATETIME_RE_SECOND, DATETIME_RE_TIMEZONE);
 		if (preg_match($pattern, $date, $matches) === 1)
 		{
 			$y = $matches[1];