-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathClockInterface.php
More file actions
115 lines (97 loc) · 2.96 KB
/
ClockInterface.php
File metadata and controls
115 lines (97 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
namespace Icecave\Chrono\Clock;
use Icecave\Chrono\Date;
use Icecave\Chrono\DateTime;
use Icecave\Chrono\Interval\Month;
use Icecave\Chrono\Interval\Year;
use Icecave\Chrono\TimeOfDay;
use Icecave\Chrono\TimePointInterface;
use Icecave\Chrono\Timer\TimerInterface;
use Icecave\Chrono\TimeSpan\TimeSpanInterface;
use Icecave\Chrono\TimeZone;
/**
* A clock is used to produce date and time measurments.
*
* In most production code {@see SystemClock} should be used.
*/
interface ClockInterface
{
/**
* @return TimeOfDay The current local time.
*/
public function localTime();
/**
* @return DateTime The current local date/time.
*/
public function localDateTime();
/**
* @return Date The current local date.
*/
public function localDate();
/**
* @return Month The current local month.
*/
public function localMonth();
/**
* @return Year The current local year.
*/
public function localYear();
/**
* @return TimeOfDay The current UTC time.
*/
public function utcTime();
/**
* @return DateTime The current UTC date/time.
*/
public function utcDateTime();
/**
* @return Date The current UTC date.
*/
public function utcDate();
/**
* @return Month The current UTC month.
*/
public function utcMonth();
/**
* @return Year The current UTC year.
*/
public function utcYear();
/**
* @return TimeZone The local timezone.
*/
public function timeZone();
/**
* @return int The current time as a unix timestamp.
*/
public function unixTime();
/**
* @return float The current time as a unix timestamp, including partial seconds.
*/
public function unixTimeAsFloat();
/**
* Sleep for the given time span.
*
* @param TimeSpanInterface|int $timeSpan A time span instance, or an integer representing seconds.
* @param bool $dispatchSignals True to dispatch to signal handlers when sleep is interrupted.
* @param bool $restart True to continue sleeping after interrupt.
*
* @return bool True if the sleep completed, false if the sleep was interrupted.
*/
public function sleep($timeSpan, $dispatchSignals = true, $restart = false);
/**
* Sleep until the given time point.
*
* @param TimePointInterface $timePoint The the point to sleep until.
* @param bool $dispatchSignals True to dispatch to signal handlers when sleep is interrupted.
* @param bool $restart True to continue sleeping after interrupt.
*
* @return bool True if the sleep completed, false if the sleep was interrupted.
*/
public function sleepUntil(TimePointInterface $timePoint, $dispatchSignals = true, $restart = false);
/**
* Create a new timer.
*
* @return TimerInterface
*/
public function createTimer();
}