File tree Expand file tree Collapse file tree 5 files changed +38
-3
lines changed
Expand file tree Collapse file tree 5 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,19 @@ Security - in case of vulnerabilities.
1818
1919_ TBD_
2020
21+ ## [ 0.4.0] 2018-02-16
22+
23+ ### Added
24+ - Added new method ` getTimestampInterval ` to returns duration in seconds ([ #18 ] ( ../../pull/18 ) ).
25+
2126## [ 0.3.0] 2017-11-18
2227
2328### Added
24- - Added new methods ` getInterval ` , ` getPeriod ` , ` split `
25- - Added ` DateRangeProvider ` interface and basic provider ` FiniteDateRangeProvider `
29+ - Added ` DateRangeProvider ` interface and basic provider ` FiniteDateRangeProvider ` ( [ # 13 ] ( ../../pull/13 ) ).
30+ - Added new method ` getDateInterval ` , ` getDatePeriod ` , ` split ` ( [ # 9 ] ( ../../pull/9 ) ).
2631
2732### Changed
28- - Rename methods from using ` time ` ot ` date ` .
33+ - Rename methods from using ` time ` ot ` date ` ( [ # 11 ] ( ../../pull/11 ) ) .
2934- Refactored internals.
3035
3136## [ 0.1.1] 2017-11-17
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ $range->isEnded();
4242$range->isStartedOn(new DateTime());
4343// Checking if range ended on specific date
4444$range->isEndedOn(new DateTime());
45+ // Accessing range duration in seconds
46+ $range->getTimestampInterval();
4547// Accessing range interval
4648$range->getDateInterval()->format('%s');
4749// Printing
Original file line number Diff line number Diff line change @@ -190,6 +190,14 @@ public function isEnded(): bool
190190 return $ this ->hasEndDate () && $ this ->state ->compareEndDate (new DateTimeImmutable ()) < 0 ;
191191 }
192192
193+ /**
194+ * {@inheritdoc}
195+ */
196+ public function getTimestampInterval (): int
197+ {
198+ return $ this ->getEndDate ()->getTimestamp () - $ this ->getStartDate ()->getTimestamp ();
199+ }
200+
193201 /**
194202 * {@inheritdoc}
195203 */
Original file line number Diff line number Diff line change @@ -112,6 +112,13 @@ public function isStarted(): bool;
112112 */
113113 public function isEnded (): bool ;
114114
115+ /**
116+ * Returns the range duration in seconds.
117+ *
118+ * @return int
119+ */
120+ public function getTimestampInterval (): int ;
121+
115122 /**
116123 * Returns the range interval.
117124 *
Original file line number Diff line number Diff line change @@ -111,6 +111,19 @@ public function dumpRange()
111111 self ::assertNotContains ('state ' , $ dump );
112112 }
113113
114+ /**
115+ * @test
116+ */
117+ public function getTimestampInterval ()
118+ {
119+ $ now = new DateTimeImmutable ();
120+ $ oneHourRange = new DateRange ($ now , $ now ->add (new DateInterval ('PT1H ' )));
121+ $ oneDayRange = new DateRange ($ now , $ now ->add (new DateInterval ('P1D ' )));
122+
123+ self ::assertSame (3600 , $ oneHourRange ->getTimestampInterval ());
124+ self ::assertSame (86400 , $ oneDayRange ->getTimestampInterval ());
125+ }
126+
114127 /**
115128 * @test
116129 */
You can’t perform that action at this time.
0 commit comments