Esempio n. 1
0
static timezone_t *
timezone_switch(const char *tz)
{
  timezone_t *self = calloc(1, sizeof *self);
  self->tz = strdup(tz_get());
  tz_set(tz && *tz ? tz : self->tz);
  return self;
}
Esempio n. 2
0
static
int
custom_get_timezone(char *s, size_t max)
{
  char buff[256];
  conf_get_str(CONF_ZONE, buff, sizeof buff, tz_get());
  tz_set(buff);
  return copy(s, max, tz_get());
}
Esempio n. 3
0
static void
timezone_restore(timezone_t *self)
{
  if( self != 0 )
  {
    tz_set(self->tz);
    free(self->tz);
    free(self);
  }
}
Esempio n. 4
0
static
int
custom_set_timezone(const char *tz)
{
  tz_set(tz);
  conf_set_str(CONF_ZONE, tz_get());

  int rc = tz_cmp(tz_get(), tz) ? -1 : 0;
  custom_send_notification(0);
  return rc;
}
Esempio n. 5
0
int set_gmt_offset(int offset, char** errmsg)
{
	int i;

	for (i = 0; timezones[i].timezone_file != NULL; ++i) {
		if (timezones[i].minute_offset == offset) {
			break;
		}
	}

	if (timezones[i].timezone_file == NULL) {
		*errmsg = strdup("Invalid timezone UTC offset.");
		return EXIT_FAILURE;
	}

	return tz_set(timezones[i].timezone_file, errmsg);
}