0.7.0 - 2024-06-23
π₯ Breaking changes
DayOfWeek
:- deprecated method
of()
has been removed, useDayOfWeek::from()
instead - the following deprecated methods have been removed, use enum values instead:
DayOfWeek::monday()
βDayOfWeek::MONDAY
DayOfWeek::tuesday()
βDayOfWeek::TUESDAY
DayOfWeek::wednesday()
βDayOfWeek::WEDNESDAY
DayOfWeek::thursday()
βDayOfWeek::THURSDAY
DayOfWeek::friday()
βDayOfWeek::FRIDAY
DayOfWeek::saturday()
βDayOfWeek::SATURDAY
DayOfWeek::sunday()
βDayOfWeek::SUNDAY
- deprecated method
getValue()
has been removed, use$dayOfWeek->value
instead - deprecated method
is()
has been removed, compare values with$dayOfWeek
or$dayOfWeek->value
instead - deprecated method
isEqualTo()
has been removed, use strict equality===
betweenDayOfWeek
instances instead.
- deprecated method
DefaultClock
:- deprecated method
travel()
has been removed, usetravelTo()
instead
- deprecated method
LocalDate
:- deprecated method
getDay()
has been removed, usegetDayOfMonth()
instead getMonth()
now returns aMonth
enum; usegetMonthValue()
if you want the month number
- deprecated method
LocalDateTime
:- deprecated method
getDay()
has been removed, usegetDayOfMonth()
instead getMonth()
now returns aMonth
enum; usegetMonthValue()
if you want the month number
- deprecated method
Month
:- deprecated method
of()
has been removed, useMonth::from()
instead - deprecated method
getAll()
has been removed, useMonth::cases()
instead - deprecated method
getValue()
has been removed, use$month->value
instead - deprecated method
is()
has been removed, compare values with$month
or$month->value
instead - deprecated method
isEqualTo()
has been removed, use strict equality===
betweenMonth
instances instead
- deprecated method
MonthDay
:- deprecated method
getDay()
has been removed, usegetDayOfMonth()
instead getMonth()
now returns aMonth
enum; usegetMonthValue()
if you want the month number
- deprecated method
YearMonth
:getMonth()
now returns aMonth
enum; usegetMonthValue()
if you want the month number
ZonedDateTime
:- deprecated method
getDay()
has been removed, usegetDayOfMonth()
instead getMonth()
now returns aMonth
enum; usegetMonthValue()
if you want the month number
- deprecated method
π§ Improvements
- Methods returning
int
are now type-annotated with int ranges
0.6.5 - 2024-06-19
β¨ New methods
LocalDate::previousDayOfWeek()
LocalDate::previousOrSameDayOfWeek()
LocalDate::nextDayOfWeek()
LocalDate::nextOrSameDayOfWeek()
0.6.4 - 2024-04-25
β¨ New features
DefaultClock::travelBy()
travels in time by a duration (#92)
π© Deprecations
DefaultClock::travel()
is now deprecated in favour oftravelTo()
(#92)
Thanks to @francislavoie!
0.6.3 - 2024-04-02
β¨ New features
Stopwatch::stop()
now returns the lap duration (#98)
Thanks to @rodnaph!
0.6.2 - 2024-04-01
β¨ New features
MonthDay::of()
andMonthDay::withMonth()
now accept aMonth
enum as parameter (#106)LocalDate::of()
andLocalDate::withMonth()
now accept aMonth
enum as parameter (#106)LocalDateTime::of()
andLocalDateTime::withMonth()
now accept aMonth
enum as parameter (#106)ZonedDateTime::withMonth()
now accepts aMonth
enum as parameter (#106)
β¨ Undeprecations
- Passing an
int
toYear::atMonth()
is un-deprecated, and now valid again (#103) - Passing an
int
toYearMonth::of()
andYearMonth::withMonth()
is un-deprecated, and now valid again (#103) - Passing an
int
toYearWeek::atDay()
is un-deprecated, and now valid again (#103)
Thanks to @gnutix!
0.6.1 - 2024-03-26
β¨ New features
Year::atMonth()
now accepts aMonth
enum as parameter (#95)YearMonth::of()
andYearMonth::withMonth()
now accept aMonth
enum as parameter (#96)
π§ Improvements
- Narrower Psalm types for
compareTo()
,__toString()
,toISOString()
,jsonSerialize()
methods (#97)
π© Deprecations
- Passing an
int
toYear::atMonth()
is now deprecated, pass aMonth
enum instead (#95) - Passing an
int
toYearMonth::of()
andYearMonth::withMonth()
is now deprecated, pass aMonth
enum instead (#96)
Thanks to @gnutix!
0.6.0 - 2023-12-05
π₯ Breaking changes
- Minimum PHP version is now 8.1
DayOfWeek
:DayOfWeek
is now anenum
: constantsMONDAY
,TUESDAY
, etc. are nowDayOfWeek
instances, not integers- the
__toString()
method is removed, usetoString()
instead (enums disallow magic methods) - the
all()
method does not acceptnull
anymore, and defaults toDayOfWeek::MONDAY
Month
:Month
is now anenum
: constantsJANUARY
,FEBRUARY
, etc. are nowMonth
instances, not integers- the
__toString()
method is removed, usetoString()
instead (enums disallow magic methods)
π© Deprecations
DayOfWeek
:- the
of()
method is deprecated, useDayOfWeek::from()
instead - the following methods are deprecated, use enum values instead:
DayOfWeek::monday()
βDayOfWeek::MONDAY
DayOfWeek::tuesday()
βDayOfWeek::TUESDAY
DayOfWeek::wednesday()
βDayOfWeek::WEDNESDAY
DayOfWeek::thursday()
βDayOfWeek::THURSDAY
DayOfWeek::friday()
βDayOfWeek::FRIDAY
DayOfWeek::saturday()
βDayOfWeek::SATURDAY
DayOfWeek::sunday()
βDayOfWeek::SUNDAY
- the
getValue()
method is deprecated, use$dayOfWeek->value
instead - the
is()
method is deprecated, compare values with$dayOfWeek->value
instead - the
isEqualTo()
method is deprecated, use strict equality===
betweenDayOfWeek
instances instead.
- the
LocalDate
:getDay()
is deprecated, usegetDayOfMonth()
insteadgetMonth()
is deprecated, usegetMonthValue()
instead (getMonth()
will be repurposed to return aMonth
instance in a future release)
LocalDateTime
:getDay()
is deprecated, usegetDayOfMonth()
insteadgetMonth()
is deprecated, usegetMonthValue()
instead (getMonth()
will be repurposed to return aMonth
instance in a future release)
Month
:- the
of()
method is deprecated, useMonth::from()
instead - the
getAll()
method is deprecated, useMonth::cases()
instead - the
getValue()
method is deprecated, use$month->value
instead - the
is()
method is deprecated, compare values with$month->value
instead - the
isEqualTo()
method is deprecated, use strict equality===
betweenMonth
instances instead
- the
MonthDay
:getDay()
is deprecated, usegetDayOfMonth()
insteadgetMonth()
is deprecated, usegetMonthValue()
instead (getMonth()
will be repurposed to return aMonth
instance in a future release)
YearMonth
:getMonth()
is deprecated, usegetMonthValue()
instead (getMonth()
will be repurposed to return aMonth
instance in a future release)
YearWeek
:- the
atDay()
method now accepts aDayOfWeek
instance, passing an integer is deprecated
- the
ZonedDateTime
:getDay()
is deprecated, usegetDayOfMonth()
insteadgetMonth()
is deprecated, usegetMonthValue()
instead (getMonth()
will be repurposed to return aMonth
instance in a future release)
0.5.5 - 2023-10-20
π Bug fixes
Year::toISOString()
/__toString()
did not respect ISO 8601; years with less than 4 digits are now left-padded with zeros (#90)
Thanks to @andreaswolf!
0.5.4 - 2023-10-16
π Bug fixes
YearMonth::__toString()
would return an invalid string for years< 1000
(#87)
β¨ New methods
Year::parse()
andYear::from()
(#86)YearWeek::parse()
andYearWeek::from()
(#86)- the following classes now have a
toISOString()
method: (#87)Duration
Instant
Interval
LocalDate
LocalDateRange
LocalDateTime
LocalTime
MonthDay
Period
Year
YearMonth
YearMonthRange
YearWeek
ZonedDateTime
The toISOString()
methods return the same result as __toString()
, but are better suited for the nullsafe operator:
$date?->toISOString();
β‘οΈ Performance optimizations
- Most
__toString()
methods got a small performance boost (#85)
Thanks to @gnutix!
0.5.3 - 2023-09-27
β¨ New methods
Thanks to @solodkiy!
0.5.2 - 2023-09-17
β‘οΈ Performance optimizations
- These methods got a small performance boost:
Local(Date|Time|DateTime)
minOf()
/maxOf()
(#76) - Static objects returned by factory methods are now cached (#77)
- The special case
LocalDate::plusDays(1)
is now much faster (#79)
Thanks to @gnutix and @BastienClement!
0.5.1 - 2023-08-01
β¨ New methods
0.5.0 - 2023-06-25
π₯ Breaking changes
-
Deprecated
Interval
constructor is nowprivate
; please useInterval::of()
instead -
The following deprecated methods have been removed, please use the new names:
Class Name Old Method Name New Method Name LocalDate
fromDateTime()
fromNativeDateTime()
LocalDate
toDateTime()
toNativeDateTime()
LocalDate
toDateTimeImmutable()
toNativeDateTimeImmutable()
LocalDateRange
toDatePeriod()
toNativeDatePeriod()
LocalDateTime
fromDateTime()
fromNativeDateTime()
LocalDateTime
toDateTime()
toNativeDateTime()
LocalDateTime
toDateTimeImmutable()
toNativeDateTimeImmutable()
LocalTime
fromDateTime()
fromNativeDateTime()
LocalTime
toDateTime()
toNativeDateTime()
LocalTime
toDateTimeImmutable()
toNativeDateTimeImmutable()
Period
fromDateInterval()
fromNativeDateInterval()
Period
toDateInterval()
toNativeDateInterval()
TimeZone
fromDateTimeZone()
fromNativeDateTimeZone()
TimeZone
toDateTimeZone()
toNativeDateTimeZone()
ZonedDateTime
fromDateTime()
fromNativeDateTime()
ZonedDateTime
toDateTime()
toNativeDateTime()
ZonedDateTime
toDateTimeImmutable()
toNativeDateTimeImmutable()
0.4.3 - 2023-06-20
π§ Improvements
TimeZoneOffset::parse()
return type has been narrowed toTimeZoneOffset
- Support for seconds in
TimeZoneOffset
has been added back (#60) (@jiripudil)
π Bug fixes
- Old date/times could fail to be parsed by
ZonedDateTime
due to sub-minute timezone offsets (#44)
0.4.2 - 2023-05-19
β¨ New methods
Duration::isGreaterThanOrEqualTo()
(#50)Duration::isLessThanOrEqualTo()
(#50)Interval::of()
(#64)Interval::contains()
(#64)Interval::intersectsWith()
(#64)Interval::getIntersectionWith()
(#64)Interval::isEqualTo()
(#64)
π© Deprecations
Interval
constructor is deprecated in favour ofInterval::of()
(#64)
0.4.1 - 2022-06-18
β¨ New methods
LocalDateRange::toPeriod()
(#51)Year::toLocalDateRange()
(#46)YearMonth::toLocalDateRange()
(#46)YearMonthRange::toLocalDateRange()
(#46)YearWeek::toLocalDateRange()
(#46)
π© Deprecations
The following methods have been deprecated in favour of new names (#47):
Period::fromDateInterval()
βfromNativeDateInterval()
Period::toDateInterval()
βtoNativeDateInterval()
TimeZone::fromDateTimeZone()
βfromNativeDateTimeZone()
TimeZone::toDateTimeZone()
βtoNativeDateTimeZone()
LocalTime::fromDateTime()
βfromNativeDateTime()
LocalTime::toDateTime()
βtoNativeDateTime()
LocalTime::toDateTimeImmutable()
βtoNativeDateTimeImmutable()
LocalDateRange::toDatePeriod()
βtoNativeDatePeriod()
LocalDate::fromDateTime()
βfromNativeDateTime()
LocalDate::toDateTime()
βtoNativeDateTime()
LocalDate::toDateTimeImmutable()
βtoNativeDateTimeImmutable()
ZonedDateTime::fromDateTime()
βfromNativeDateTime()
ZonedDateTime::toDateTime()
βtoNativeDateTime()
ZonedDateTime::toDateTimeImmutable()
βtoNativeDateTimeImmutable()
LocalDateTime::fromDateTime()
βfromNativeDateTime()
LocalDateTime::toDateTime()
βtoNativeDateTime()
LocalDateTime::toDateTimeImmutable()
βtoNativeDateTimeImmutable()
0.4.0 - 2021-12-23
π₯ Breaking changes
- Minimum PHP version is now 7.4
TimeZoneOffset
does not allow seconds anymore (#35):TimeZoneOffset::of()
's$seconds
parameter is removedTimeZoneOffset::ofTotalSeconds()
now throws if the number of seconds is not a multiple of60
IsoParsers::timeZoneOffset()
does not allow seconds in timezone offset anymore; this affects not onlyTimeZoneOffset:parse()
but alsoZonedDateTime::parse()
π§ Fix
- Fixed return type of
TimeZoneRegion::parse()
(#38) Thanks to @adrianguenter
β¨ New methods
Period::fromDateInterval()
converts a nativeDateInterval
object toPeriod
0.3.2 - 2021-06-30
β¨ New methods
DayOfWeek::isWeekday()
DayOfWeek::isWeekend()
LocalDate::plusWeekdays()
LocalDate::minusWeekDays()
0.3.1 - 2021-06-29
β¨ New methods
LocalDateRange::withStart()
LocalDateRange::withEnd()
0.3.0 - 2021-04-24
π₯ Breaking changes
- The following methods now have return types:
Brick\DateTime\DayOfWeek::monday()
throughsunday()
Brick\DateTime\DayOfWeek::__toString()
Brick\DateTime\Month::__toString()
0.2.3 - 2021-02-26
β¨ New method
LocalDateRange::toDatePeriod()
(#31) Thanks to @morrislaptop
π§ Fix
- Added missing
ext-json
requirement incomposer.json
0.2.2 - 2020-07-30
π Bug fix
LocalDateTime::plusDuration()
and LocalDateTime::minusDuration()
could return the wrong day. (#25)
Thanks @JodyLognoul!
0.2.1 - 2020-04-06
β¨ New methods
LocalDateRange::intersectsWith()
LocalDateRange::getIntersectionWith()
Thanks @solodkiy!
0.2.0 - 2020-01-08
π₯ Breaking changes
- most of the project classes are now
final
(#8) - the following deprecated methods have been removed:
LocalDateRange::getStartDate()
- usegetStart()
instead (#13)LocalDateRange::getEndDate()
- usegetEnd()
instead (#13)Duration::ofMilliseconds()
- useofMillis()
instead
0.1.16 - 2020-01-08
β¨ New methods
LocalDateRange::getStart()
- deprecatesgetStartDate()
LocalDateRange::getEnd()
- deprecatesgetEndDate()
π© Deprecations
LocalDateRange::getStartDate()
is now deprecated and will be removed in0.2.0
.LocalDateRange::getEndDate()
is now deprecated and will be removed in0.2.0
.
This makes LocalDateRange
consistent with YearMonthRange
.
0.1.15 - 2020-01-07
π Improvement
The following classes now implement JsonSerializable
(#19):
DayOfWeek
Duration
Instant
Interval
LocalDate
LocalDateRange
LocalDateTime
LocalTime
Month
MonthDay
Period
Year
YearMonth
YearMonthRange
YearWeek
ZonedDateTime
Thanks to @kagmole!
0.1.14 - 2019-09-17
β¨ New methods
Duration::toDays()
Duration::toDaysPart()
Duration::toHours()
Duration::toHoursPart()
Duration::toMinutes()
Duration::toMinutesPart()
Duration::toSeconds()
Duration::toSecondsPart()
Duration::toMillis()
Duration::toMillisPart()
Duration::toNanos()
Duration::toNanosPart()
Duration::ofNanos()
See #15 for more information.
π© Deprecations
Duration::ofMilliseconds()
is nowofMillis()
;ofMilliseconds()
is now deprecated and will be removed in0.2.0
.
0.1.13 - 2019-04-17
New methods
LocalDateTime::isFuture()
LocalDateTime::isPast()
These methods return whether a local date-time is in the future or in the past, in a given time-zone.
0.1.12 - 2019-04-15
New methods
Instant::withEpochSecond()
returns a copy of theInstant
with the epoch second alteredInstant::withNano()
returns a copy of theInstant
with the nano-of-second altered
0.1.11 - 2019-03-08
New class: YearMonthRange
.
0.1.10 - 2019-03-08
LocalDateRange::getIterator()
is now type-hinted as LocalDate[]
to allow static code analysis in IDEs.
0.1.9 - 2018-11-14
New method: LocalDate::daysUntil()
This allows to get the number of days between two dates.
0.1.8 - 2018-10-29
New methods to convert objects to native DateTimeImmutable
objects:
LocalDate::toDateTimeImmutable()
LocalTime::toDateTimeImmutable()
LocalDateTime::toDateTimeImmutable()
ZonedDateTime::toDateTimeImmutable()
0.1.7 - 2018-10-18
New methods to convert to native DateTime
objects:
LocalDate::toDateTime()
LocalTime::toDateTime()
LocalDateTime::toDateTime()
This makes these methods in line with their fromDateTime()
counterparts.
Note: even though these classes represent partial date-time concepts, PHP merges all these concepts into a single DateTime
class, so it is relevant to be able to easily export them as native PHP date-times, with sensible defaults.
0.1.6 - 2018-10-18
New method:
ZonedDateTime::toDateTime()
: converts the ZonedDateTime
to a native DateTime
object.
0.1.5 - 2018-10-13
New factory method:
Duration::ofMilliseconds()
0.1.4 - 2018-03-14
New methods available to create objects from native DateTime
or DateTimeImmutable
objects:
LocalDate::fromDateTime()
LocalTime::fromDateTime()
LocalDateTime::fromDateTime()
ZonedDateTime::fromDateTime()
0.1.3 - 2018-02-06
This release adds support for YearWeek
.
0.1.2 - 2017-10-04
Bug fix:
Duration::multipliedBy()
could return an invalid Duration with negative nanos
New methods:
Instant::toDecimal()
returns a decimal timestamp such as123456789.123456
FixedClock::move()
allows to move the clock by a number of seconds and/or nanos
New clock implementation:
ScaleClock
makes the time move at a given pace
New feature:
- Methods such as
now()
now use the clock returned byDefaultClock
. By default, this clock is stillSystemClock
, but it can now be overridden in tests. DefaultClock offers thefreeze()
,travel()
andscale()
methods inspired by timecop.
0.1.1 - 2017-10-04
ZonedDateTime::isPast()
and isFuture()
now accept an optional Clock
parameter.
0.1.0 - 2017-10-04
First beta release.