Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PHP does not parse “BRST” dates anymore?

Tags:

php

datetime

BRST refers to "Brasília Summer Time"

Before version 7.0.26, PHP could parse this string without any problem:

$date = DateTime("Mon Jan 01 20:00:00 BRST 2017");

After that version, PHP returns:

Fatal error: Uncaught Exception: DateTime::__construct(): Failed to 
parse time string (Mon Jan 01 20:00:00 BRST 2017) at position 4 (J): 
The timezone could not be found in the database in /in/c6K56:5
Stack trace:
#0 /in/c6K56(5): DateTime->__construct('Mon Jan 01 20:0...')
#1 {main}
  thrown in /in/c6K56 on line 5

Process exited with code 255.

I searched in changelogs, but I couldn't find any explanation for that.

Here is the example:

https://3v4l.org/c6K56#v7026

like image 732
hugofcampos Avatar asked Jan 03 '18 12:01

hugofcampos


1 Answers

You can see in this commit the timezonemap.h file was updated to remove the references to brst along with many other abbreviations.

The commit message reads:

Update timezonemap.h, which needs to match the bundled TZ db


Digging deeper (thanks @JamesThorpe) you can see the abbreviations were introduced in July 1999 by Paul Eggert. Notably he claims to have invented these himself:

I invented the English-language abbreviations, and I also invented the other rows to be consistent with the -3:00 row.

This tz commit in December 2016 (again by Eggert) removes the abbreviations and replaces them with the following text:

These tables use numeric abbreviations like -03 and -0330 for integer hour and minute UTC offsets. Although earlier editions used alphabetic time zone abbreviations, these abbreviations were invented and did not reflect common practice.

like image 176
timclutton Avatar answered Sep 30 '22 06:09

timclutton