13
13
*/
14
14
class DateTime
15
15
{
16
- /**
17
- * Current config offset in seconds
18
- *
19
- * @var int
20
- */
21
- private $ _offset = 0 ;
22
-
23
16
/**
24
17
* @var TimezoneInterface
25
18
*/
@@ -31,7 +24,6 @@ class DateTime
31
24
public function __construct (TimezoneInterface $ localeDate )
32
25
{
33
26
$ this ->_localeDate = $ localeDate ;
34
- $ this ->_offset = $ this ->calculateOffset ($ this ->_localeDate ->getConfigTimezone ());
35
27
}
36
28
37
29
/**
@@ -78,8 +70,7 @@ public function gmtDate($format = null, $input = null)
78
70
}
79
71
80
72
/**
81
- * Converts input date into date with timezone offset
82
- * Input date must be in GMT timezone
73
+ * Converts input date into date with timezone offset. Input date must be in GMT timezone.
83
74
*
84
75
* @param string $format
85
76
* @param int|string $input date in GMT timezone
@@ -122,8 +113,7 @@ public function gmtTimestamp($input = null)
122
113
}
123
114
124
115
/**
125
- * Converts input date into timestamp with timezone offset
126
- * Input date must be in GMT timezone
116
+ * Converts input date into timestamp with timezone offset. Input date must be in GMT timezone.
127
117
*
128
118
* @param int|string $input date in GMT timezone
129
119
* @return int
@@ -157,18 +147,18 @@ public function timestamp($input = null)
157
147
*/
158
148
public function getGmtOffset ($ type = 'seconds ' )
159
149
{
160
- $ result = $ this ->_offset ;
150
+ $ offset = $ this ->calculateOffset ( $ this -> _localeDate -> getConfigTimezone ()) ;
161
151
switch ($ type ) {
162
152
case 'seconds ' :
163
153
default :
164
154
break ;
165
155
case 'minutes ' :
166
- $ result = $ result / 60 ;
156
+ $ offset = $ offset / 60 ;
167
157
break ;
168
158
case 'hours ' :
169
- $ result = $ result / 60 / 60 ;
159
+ $ offset = $ offset / 60 / 60 ;
170
160
break ;
171
161
}
172
- return $ result ;
162
+ return $ offset ;
173
163
}
174
164
}
0 commit comments