Time value objects, parsers and formatters

Installs: 65 051

Dependents: 8

Stars: 4

Watchers: 8

Forks: 1

Open Issues: 4

Language: PHP

0.8.0 2015-06-26 08:41 UTC

README

Library containing value objects to represent temporal information, parsers to turn user input into such value objects, and formatters to turn them back into user consumable representations.

It is part of the DataValues set of libraries.

Build Status Code Coverage Scrutinizer Quality Score Dependency Status

On Packagist: Latest Stable Version Download count

Installation

The recommended way to use this library is via Composer.

Composer

To add this package as a local, per-project dependency to your project, simply add a dependency on data-values/time to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on version 1.0 of this package:

    {
        "require": {
            "data-values/time": "1.0.*"
        }
    }

Manual

Get the code of this package, either via git, or some other means. Also get all dependencies. You can find a list of the dependencies in the "require" section of the composer.json file. Then take care of autoloading the classes defined in the src directory.

Tests

This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run via TravisCI, as a TravisCI configuration file is also provided in the root directory.

Authors

DataValues Time has been written by the Wikidata team, as Wikimedia Germany employees for the Wikidata project.

Release notes

0.8.1 (dev)

Additions
  • Added YearMonthDayTimeParser
  • PhpDateTimeParser now accepts space-separated dates in YMD order

0.8.0 (2015-06-26)

Breaking changes
  • IsoTimestampParser auto-detects the calendar model and does not default to Gregorian any more
  • Removed IsoTimestampParser::PRECISION_NONE, use null instead
  • TimeValues leap second range changed from [0..62] to [0..61]
Additions
  • Added EraParser
  • Added TimeValue::CALENDAR_GREGORIAN and TimeValue::CALENDAR_JULIAN
  • Renamed all TimeValue::PRECISION_... constants with lower case letters, e.g. PRECISION_10a to PRECISION_YEAR10, leaving backwards compatible aliases
  • IsoTimestampParser now accepts time values with optional colons, per ISO
  • PhpDateTimeParser now accepts comma separated dates
Other changes
  • Fixed IsoTimestampParser not being able to set precision to hour, minute or second on midnight
  • Deprecated IsoTimestampParser::CALENDAR_GREGORIAN and IsoTimestampParser::CALENDAR_JULIAN
  • Deprecated TimeFormatter::CALENDAR_GREGORIAN and TimeFormatter::CALENDAR_JULIAN

0.7.0 (2015-04-20)

Breaking changes
  • Renamed TimeParser to IsoTimestampParser
  • Empty strings are now detected as invalid calendar models in the TimeValue constructor
Additions
  • Added MonthNameUnlocalizer
  • Added PhpDateTimeParser
  • IsoTimestampParser can now parse various YMD ordered timestamp strings resembling ISO 8601
  • CalendarModelParser now accepts URIs and localized calendar names given via options
Other changes
  • The year in TimeValues is now padded to 4 digits, and additional leading zeros are trimmed
  • Major update of the TimeValue documentation
  • Constructor arguments in IsoTimestampParser and TimeFormatter are optional now
  • Fixed TimeFormatter delegating to an ISO timestamp formatter given via option
  • TimeFormatter does not output the calendar model any more

0.6.1 (2014-10-09)

  • Made component installable with DataValues 1.x

0.6.0 (2014-06-05)

  • Added TimeValueCalculator
  • Removed TimeIsoFormatter interface
  • Introduced FORMAT_NAME class constants on ValueParsers in order to use them as expectedFormat
  • Changed ValueParsers to pass rawValue and expectedFormat arguments when constructing a ParseException

0.5.2 (2014-04-28)

  • Fix parsing of years ending in zero, defaulting precision to year when year is <= 4000 and >= 4000 BC.

0.5.1 (2014-03-24)

  • Fix composer version of DataValues/Common

0.5.0 (2014-03-21)

  • Removed TimeParser::SIGN_PATTERN constant
  • Removed TimeParser::TIME_PATTERN constant
  • Fixed bug 62730. The TimeParser now returns the correct precision when only month and year or year is given

0.4.0 (2014-03-14)

  • Corrected spelling errors calender/calander -> calendar

0.3.0 (2014-03-13)

  • Renamed CalenderModelParser to CalendarModelParser
  • Added Calandar and Precision options to TimeParser

0.2.0 (2014-02-11)

Added features:

  • TimeParser
  • CalenderModelParser

0.1.0 (2013-11-17)

Initial release with these features:

  • TimeValue
  • TimeFormatter
  • TimeIsoFormatter

Links