1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Extract a function, ruby_reset_timezone().

Initial implementation of ruby_reset_timezone()
assigns ruby_tz_uptodate_p to false.
This commit is contained in:
Tanaka Akira 2020-01-28 23:40:25 +09:00
parent fb41246ddb
commit 338c5b8c1d
3 changed files with 10 additions and 3 deletions

6
hash.c
View file

@ -35,6 +35,7 @@
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/symbol.h"
#include "internal/time.h"
#include "internal/vm.h"
#include "probes.h"
#include "ruby/st.h"
@ -4758,7 +4759,6 @@ env_str_new2(const char *ptr)
}
static const char TZ_ENV[] = "TZ";
extern bool ruby_tz_uptodate_p;
static rb_encoding *
env_encoding_for(const char *name, const char *ptr)
@ -4843,7 +4843,7 @@ env_delete(VALUE name)
* This hack might works only on Linux glibc.
*/
if (ENVMATCH(nam, TZ_ENV)) {
ruby_tz_uptodate_p = FALSE;
ruby_reset_timezone();
}
if (val) {
@ -5275,7 +5275,7 @@ env_aset(VALUE nm, VALUE val)
RB_GC_GUARD(nm);
}
else if (ENVMATCH(name, TZ_ENV)) {
ruby_tz_uptodate_p = FALSE;
ruby_reset_timezone();
}
return val;
}

View file

@ -29,6 +29,7 @@ struct timeval rb_time_timeval(VALUE);
RUBY_SYMBOL_EXPORT_BEGIN
/* time.c (export) */
void ruby_reset_leap_second_info(void);
void ruby_reset_timezone(void);
RUBY_SYMBOL_EXPORT_END
#endif /* INTERNAL_TIME_H */

6
time.c
View file

@ -683,6 +683,12 @@ static VALUE tm_from_time(VALUE klass, VALUE time);
bool ruby_tz_uptodate_p;
void
ruby_reset_timezone(void)
{
ruby_tz_uptodate_p = false;
}
static void
update_tz(void)
{