Skip to content

Commit 5f394fd

Browse files
committed
feat: add isPast() and isFuture() time convenience methods
1 parent 455068a commit 5f394fd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

system/I18n/TimeTrait.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,26 @@ public function isAfter($testTime, ?string $timezone = null): bool
10281028
return $ourTimestamp > $testTimestamp;
10291029
}
10301030

1031+
/**
1032+
* Determines if the current instance's time is in the past.
1033+
*
1034+
* @throws Exception
1035+
*/
1036+
public function isPast(): bool
1037+
{
1038+
return $this->isBefore(static::now($this->timezone));
1039+
}
1040+
1041+
/**
1042+
* Determines if the current instance's time is in the future.
1043+
*
1044+
* @throws Exception
1045+
*/
1046+
public function isFuture(): bool
1047+
{
1048+
return $this->isAfter(static::now($this->timezone));
1049+
}
1050+
10311051
// --------------------------------------------------------------------
10321052
// Differences
10331053
// --------------------------------------------------------------------

0 commit comments

Comments
 (0)