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.
On Packagist:
The recommended way to use this library is via 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.x of this package:
{
"require": {
"data-values/time": "~1.2"
}
}
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.
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.
DataValues Time has been written by the Wikidata team, as Wikimedia Germany employees for the Wikidata project.
- Drop support for PHP 7.2, 7.3
- Upgrade codesniffer rules to current
mediawiki/mediawiki-codesniffer
version (45.0.0) - Make nullable type parameter declarations explicit for compatibility with PHP 8.4
- Allow installation together with data-values/common 1.1.0 and data-values/interfaces 1.x
- Allow installation together with DataValues 3.1
- Improved compatibility with PHP 8.1;
in particular, the new
__serialize
/__unserialize
methods are implemented now (in addition to the still supportedSerializable
interface). Make sure to also usedata-values/data-values
version 3.1.0 (or later) to keep hashes stable. - Added support for the YYYY-DDD format (DDDth day of the year) added in PHP 8.1.7. (Not supported in earlier PHP versions.)
- Support month+year dates with era
- Update major
data-values/*
versions
- Fixed parsing unicode month names
- Parse and refuse invalid calendar option
- Removed
DATAVALUES_TIME_VERSION
constant - Allow installation together with DataValues 2.x
- Added whitespace trimming to
YearTimeParser
. - Fixed
IsoTimestampParser
andTimeValue
accepting a time of day with no day. - Fixed
MonthNameUnlocalizer
accidentally replacing already unlocalized numeric months. - Fixed
PhpDateTimeParser
misinterpreting inputs with only one or two numbers. - Deprecated
TimeValue::newFromArray
. - Raised required PHP version from 5.3 to 5.5.
- Removed MediaWiki integration
- Bump data-values/common dependency
- Added
MonthNameProvider
interface. - Added
MonolingualMonthNameProvider
. - Added
YearMonthTimeParser
. - Added
YearTimeParser
.
- Added optional
ParserOptions
parameter to theYearMonthDayTimeParser
constructor. - Fixed
YearMonthDayTimeParser
not accepting calendar model and precision options. - Fixed
IsoTimestampParser
not accepting string precisions. - Fixed
IsoTimestampParser
not always throwing an exception on invalid precisions. - Fixed
FORMAT_NAME
constants in parsers.
- Fixed
IsoTimestampParser
andTimeValue
accepting days with no month. - Fixed
YearMonthDayTimeParser
rejecting YDM dates. YearMonthDayTimeParser
accepts some more dates where month and day are the same anyway.
- Added
YearMonthDayTimeParser
. PhpDateTimeParser
now accepts space-separated dates in YMD order.
- The component can now be installed together with DataValues Interfaces 0.2.x.
- The component can now be installed together with DataValues Common 0.3.x.
IsoTimestampParser
auto-detects the calendar model and does not default to Gregorian any more- Removed
IsoTimestampParser::PRECISION_NONE
, usenull
instead TimeValue
s leap second range changed from [0..62] to [0..61]
- Added
EraParser
- Added
TimeValue::CALENDAR_GREGORIAN
andTimeValue::CALENDAR_JULIAN
- Renamed all
TimeValue::PRECISION_...
constants with lower case letters, e.g.PRECISION_10a
toPRECISION_YEAR10
, leaving backwards compatible aliases IsoTimestampParser
now accepts time values with optional colons, per ISOPhpDateTimeParser
now accepts comma separated dates
- Fixed
IsoTimestampParser
not being able to set precision to hour, minute or second on midnight - Deprecated
IsoTimestampParser::CALENDAR_GREGORIAN
andIsoTimestampParser::CALENDAR_JULIAN
- Deprecated
TimeFormatter::CALENDAR_GREGORIAN
andTimeFormatter::CALENDAR_JULIAN
- Renamed
TimeParser
toIsoTimestampParser
- Empty strings are now detected as invalid calendar models in the
TimeValue
constructor
- Added
MonthNameUnlocalizer
- Added
PhpDateTimeParser
IsoTimestampParser
can now parse various YMD ordered timestamp strings resembling ISO 8601CalendarModelParser
now accepts URIs and localized calendar names given via options
- The year in
TimeValue
s is now padded to 4 digits, and additional leading zeros are trimmed - Major update of the
TimeValue
documentation - Constructor arguments in
IsoTimestampParser
andTimeFormatter
are optional now - Fixed
TimeFormatter
delegating to an ISO timestamp formatter given via option TimeFormatter
does not output the calendar model any more
- Made component installable with DataValues 1.x
- 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
- Fix parsing of years ending in zero, defaulting precision to year when year is <= 4000 and >= 4000 BC.
- Fix composer version of DataValues/Common
- 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
- Corrected spelling errors calender/calander -> calendar
- Renamed CalenderModelParser to CalendarModelParser
- Added Calandar and Precision options to TimeParser
Added features:
- TimeParser
- CalenderModelParser
Initial release with these features:
- TimeValue
- TimeFormatter
- TimeIsoFormatter