GSoC 2010 – week summary: June 7th – June 13th
My goal for this week was to implement a class for formatting date and / or time. I created a class DatesReader, which is, like NumbersReader and PluralsReader created before, kind of wrapper for particular tags of CLDR XML data, providing an API for using this data in FLOW3 framework.
DatesReader parses most data from dates tag, that is: months, days, quarters, dayPeriods, eras, dateFormats, timeFormats and dateTimeFormats. The most important functionality of DatesReader is of course, date and time formatting. Syntax for date / time format defined in CLDR is pretty extensive (see the specification). Most of it is supported by DatesReader class. As in NumbersReader, the solution for dateTime formatting in Yii Framework was very useful, although I extended it, so the specification is supported even more precisely. These are examples of supported formats (one format per line):
yyyy.MM.dd G HH:mm:ss zzz EEE, MMM d, 'yy hh o'clock a, zzzz
Formats are parsed and stored in cache. DatesReader can format date, time or dateTime (both date and time in one string) – it uses formats defined in CLDR for particular locale. It can also format dateTime using custom format pattern. This class uses DateTime PHP object as a representation of date and time.
DatesReader was commited in Revision 4504 (update: actually in r4512 as I forgot to add new files :-)).
I also thoroughly changed CLDRModel class (and HierarchicalCLDRModel). First of all, parsing of CLDR data is changed – internal array generated from CLDR is now much simpler, which I found much more robust and useful. It was easier to support alias tag which is used in CLDR to point places where actual data is placed (in order to not duplicate data in different parts of XML file). I also changed API for CLDRModel, and I think it’s now more useful.
DatesReader is the last of CLDR classes I planned to implement. CLDR is very extensive and a lot more data could be used, but I’m afraid I won’t have time for the rest of my proposal. So, now I will proceed to the next task, which is support for XLIFF files. XLIFF is a XML format for storing translation messages (labels). If I will have time at the end of coding period, I will return to CLDR.