Page MenuHomePhabricator

Timestamp with zone and PostgreSQL
Closed, ResolvedPublic

Description

Author: merdier

Description:
The date fields are created with the 'timestamptz' type under PostgreSQL so the
time zone should be supported.
in this case, 'wfTimestamp' (GlobalFunctions.php) can receive a date like this
one : '2006-07-11 10:36:00+02'.

I propose to add these lines :
function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
$uts = 0;
$da = array();
if ($ts==0) {

		$uts=time();

} elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d)
(\d\d):(\d\d):(\d\d)$/D",$ts,$da)) {

  1. TS_DB
		$uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
			    (int)$da[2],(int)$da[3],(int)$da[1]);

+ } elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d)
(\d\d):(\d\d):(\d\d)\+(\d\d)$/D",$ts,$da)) {
+ # TS_DBTZ
+ $uts=gmmktime((int)$da[4] + (int)$da[7],(int)$da[5],(int)$da[6],
+ (int)$da[2],(int)$da[3],(int)$da[1]);


Version: 1.7.x
Severity: normal
OS: Linux
Platform: PC

Details

Reference
bz6632

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 9:17 PM
bzimport set Reference to bz6632.
bzimport added a subscriber: Unknown Object (MLST).

xzilla wrote:

adds postgresql time format definition

Attached:

xzilla wrote:

I'm not sure I fully understand the above. AFAICT the issue I have had with
postgresql is that the mediawiki software attempts to operate as if the db is
working in GMT, which throws off timestamps which may be at a different
timezone. The attached patch implements a POSTGRES timestamp definition within
mediawiki, and adjusts it accordingly. This method worked well for wikipgedia.

I think bigger error is to create date fields with timezone information.
Initial PG support did use 'timestamp without timezone' everywhere.

Going to close this for now as resolved: if specific timestamp related errors
come up, please reopen of open a new bug.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.