@@ -28,17 +28,27 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2828
2929#if defined(__WINDOWS__)
3030static bool
31- MCDateGetLocalTimeInfo (struct tm & r_timeinfo,
32- long & r_timezone)
31+ MCDateGetTimeInfo (bool t_is_local,
32+ struct tm & r_timeinfo,
33+ long & r_timezone)
3334{
34- _get_timezone (&t_timezone);
35+ if (t_is_local)
36+ {
37+ _get_timezone (&r_timezone);
38+ }
39+ else
40+ {
41+ r_timezone = 0 ;
42+ }
3543
3644 time_t t_now;
3745 time (&t_now);
3846
3947 /* Windows doesn't have localtime_r(), but it does have an equivalent
4048 * function with the arguments in the opposite order! */
41- if (0 != localtime_s (&r_timeinfo, &t_time))
49+ if (0 != (t_is_local
50+ ? localtime_s (&r_timeinfo, &t_time)
51+ : gmtime_s (&r_timeinfo, &t_time)))
4252 {
4353 return false ;
4454 }
@@ -48,13 +58,16 @@ MCDateGetLocalTimeInfo(struct tm & r_timeinfo,
4858
4959#elif defined(__MAC__) || defined(__IOS__)
5060static bool
51- MCDateGetLocalTimeInfo (struct tm & r_timeinfo,
52- long & r_timezone)
61+ MCDateGetTimeInfo (bool t_is_local,
62+ struct tm & r_timeinfo,
63+ long & r_timezone)
5364{
5465 time_t t_now;
5566 time (&t_now);
5667
57- if (NULL == localtime_r (&t_now, &r_timeinfo))
68+ if (NULL == (t_is_local
69+ ? localtime_r (&t_now, &r_timeinfo)
70+ : gmtime_r (&t_now, &r_timeinfo)))
5871 {
5972 return false ;
6073 }
@@ -66,37 +79,48 @@ MCDateGetLocalTimeInfo(struct tm & r_timeinfo,
6679
6780#elif defined(__LINUX__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__)
6881static bool
69- MCDateGetLocalTimeInfo (struct tm & r_timeinfo,
70- long & r_timezone)
82+ MCDateGetTimeInfo (bool t_is_local,
83+ struct tm & r_timeinfo,
84+ long & r_timezone)
7185{
7286 time_t t_now;
7387 time (&t_now);
7488
75- if (NULL == localtime_r (&t_now, &r_timeinfo))
89+ if (NULL == (t_is_local
90+ ? localtime_r (&t_now, &r_timeinfo)
91+ : gmtime_r (&t_now, &r_timeinfo)))
7692 {
7793 return false ;
7894 }
7995
80- /* FIXME This may be expensive, but is probably required if
81- * MCDateGetLocalTimeInfo() is to behave properly over summer time
82- * changes. */
83- tzset ();
84- r_timezone = timezone;
96+ if (t_is_local)
97+ {
98+ /* FIXME This may be expensive, but is probably required if
99+ * MCDateGetTimeInfo() is to behave properly over summer time
100+ * changes. */
101+ tzset ();
102+ r_timezone = timezone;
103+ }
104+ else
105+ {
106+ r_timezone = 0 ;
107+ }
85108
86109 return true ;
87110}
88111
89112#else
90- # error "MCDateGetLocalTimeInfo () not implemented for this platform"
113+ # error "MCDateGetTimeInfo () not implemented for this platform"
91114#endif
92115
93- extern " C" MC_DLLEXPORT_DEF void
94- MCDateExecGetLocalDate (MCProperListRef & r_datetime)
116+ static void
117+ MCDateExecGetDate (bool t_is_local,
118+ MCProperListRef & r_datetime)
95119{
96120 struct tm t_timeinfo;
97121 long t_timezone;
98122
99- if (!MCDateGetLocalTimeInfo ( t_timeinfo, t_timezone))
123+ if (!MCDateGetTimeInfo (t_is_local, t_timeinfo, t_timezone))
100124 {
101125 return ;
102126 }
@@ -120,6 +144,18 @@ MCDateExecGetLocalDate (MCProperListRef & r_datetime)
120144 return ;
121145}
122146
147+ extern " C" MC_DLLEXPORT_DEF void
148+ MCDateExecGetLocalDate (MCProperListRef & r_datetime)
149+ {
150+ MCDateExecGetDate (true , r_datetime);
151+ }
152+
153+ extern " C" MC_DLLEXPORT_DEF void
154+ MCDateExecGetUniversalDate (MCProperListRef & r_datetime)
155+ {
156+ MCDateExecGetDate (false , r_datetime);
157+ }
158+
123159extern " C" MC_DLLEXPORT_DEF void
124160MCDateExecGetUniversalTime (double & r_time)
125161{
0 commit comments