@@ -31,11 +31,11 @@ class ClientTimezone
3131 const CLIENT_TIMEZONE_POST = "clienttimezone " ;
3232
3333 /**
34- * Flag to skip getting the client timezone
34+ * The session key for if checking the client timezone should be skipped
3535 *
36- * @var boolean
36+ * @var string
3737 */
38- protected static $ skip = FALSE ;
38+ const CLIENT_TIMEZONE_SKIP = " clienttimezoneskip " ;
3939
4040
4141 /**
@@ -45,7 +45,7 @@ class ClientTimezone
4545 *
4646 * @return string
4747 */
48- protected static function getSessionKey ()
48+ protected static function getOffsetSessionKey ()
4949 {
5050 return env ('CLIENT_TIMEZONE_SESSION ' , self ::CLIENT_TIMEZONE_SESSION );
5151 }
@@ -62,14 +62,24 @@ public static function getPostUrl()
6262 return env ('CLIENT_TIMEZONE_POST ' , self ::CLIENT_TIMEZONE_POST );
6363 }
6464
65+ /**
66+ * Returns the session key where the skip flag is stored
67+ *
68+ * @return string
69+ */
70+ protected static function getSkipSessionKey ()
71+ {
72+ return env ('CLIENT_TIMEZONE_SKIP ' , static ::CLIENT_TIMEZONE_SKIP );
73+ }
74+
6575 /**
6676 * Returns if the client timezone is stored in session or not
6777 *
6878 * @return boolean
6979 */
70- public static function hasOffset ()
80+ protected static function hasOffset ()
7181 {
72- return Session::has (static ::getSessionKey ());
82+ return Session::has (static ::getOffsetSessionKey ());
7383 }
7484
7585 /**
@@ -82,7 +92,7 @@ public static function getOffset()
8292 {
8393 if (static ::hasOffset ())
8494 {
85- return intval (Session::get (static ::getSessionKey ()));
95+ return intval (Session::get (static ::getOffsetSessionKey ()));
8696 }
8797 return NULL ;
8898 }
@@ -94,32 +104,42 @@ public static function getOffset()
94104 */
95105 public static function setOffset ($ offset )
96106 {
97- Session::put (static ::getSessionKey (), intval ($ offset ));
107+ Session::put (static ::getOffsetSessionKey (), intval ($ offset ));
98108 }
99109
100110 /**
101111 * Removes the timezone offset from the session
102112 */
103113 public static function forget ()
104114 {
105- Session::forget (static ::getSessionKey ());
115+ Session::forget (static ::getOffsetSessionKey ());
106116 }
107117
108118 /**
109119 * Sets the skip flag to true, meaning that the javascript will not check for the client timezone
110120 */
111121 public static function skip ()
112122 {
113- static ::$ skip = TRUE ;
123+ Session::flash (static ::getSkipSessionKey (), TRUE );
124+ }
125+
126+ /**
127+ * Returns if checking the client timezone is going to be skipped or not
128+ *
129+ * @return boolean
130+ */
131+ protected static function skipping ()
132+ {
133+ return Session::has (static ::getSkipSessionKey ()) && Session::get (static ::getSkipSessionKey ()) == TRUE ;
114134 }
115135
116136 /**
117- * Returns if the client timezone should be checked or not
137+ * Returns if the client timezone will be checked or not
118138 *
119139 * @return boolean
120140 */
121- public static function check ()
141+ public static function checking ()
122142 {
123- return !static ::$ skip && is_null (static ::getOffset ());
143+ return !static ::skipping () && is_null (static ::getOffset ());
124144 }
125145}
0 commit comments