Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/amiga/filedate.c view on Meta::CPAN
if (len) {
if (hand = Open((char *) var, MODE_NEWFILE)) {
ret = Write(hand, (char *) value, len + 1) >= len;
Close(hand);
}
} else
ret = DeleteFile((char *) var);
UnLock(CurrentDir(spine));
}
}
me->pr_WindowPtr = old_window;
return ret;
}
/* Stores data from timezone and daylight to ENV:TZ. */
/* ENV:TZ is required to exist by some other SAS/C library functions, */
/* like stat() or fstat(). */
void set_TZ(long time_zone, int day_light)
{
char put_tz[MAXTIMEZONELEN]; /* string for putenv: "TZ=aaabbb:bb:bbccc" */
int offset;
void *exists; /* dummy ptr to see if global envvar TZ already exists */
exists = (void *)getenv(TZ_ENVVAR);
/* see if there is already an envvar TZ_ENVVAR. If not, create it */
if (exists == NULL) {
/* create TZ string by pieces: */
sprintf(put_tz, "GMT%+ld", time_zone / 3600L);
if (time_zone % 3600L) {
offset = (int) labs(time_zone % 3600L);
sprintf(put_tz + strlen(put_tz), ":%02d", offset / 60);
if (offset % 60)
sprintf(put_tz + strlen(put_tz), ":%02d", offset % 60);
}
if (day_light)
strcat(put_tz,"DST");
setenv(TZ_ENVVAR, put_tz, 1);
}
}
#endif /* __SASC */
/* set state as well as possible from settings found in locale.library */
int GetPlatformLocalTimezone(sp, fill_tzstate_from_rules)
register struct state * ZCONST sp;
void (*fill_tzstate_from_rules)(struct state * ZCONST sp_res,
ZCONST struct rule * ZCONST start,
ZCONST struct rule * ZCONST end);
{
struct Library *LocaleBase;
struct Locale *ll;
struct Process *me = (void *) FindTask(NULL);
void *old_window = me->pr_WindowPtr;
BPTR eh;
int z, valid = FALSE;
/* read timezone from locale.library if TZ envvar missing */
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
if (LocaleBase = OpenLibrary("locale.library", 0)) {
if (ll = OpenLocale(NULL)) {
z = ll->loc_GMTOffset; /* in minutes */
if (z == -300) {
if (eh = Lock("ENV:sys/locale.prefs", ACCESS_READ)) {
UnLock(eh);
valid = TRUE;
} else
z = 300; /* bug: locale not initialized, default bogus! */
} else
valid = TRUE;
if (valid) {
struct rule startrule, stoprule;
sp->timecnt = 0;
sp->typecnt = 1;
sp->charcnt = 2;
sp->chars[0] = sp->chars[1] = '\0';
sp->ttis[0].tt_abbrind = 0;
sp->ttis[1].tt_abbrind = 1;
sp->ttis[0].tt_gmtoff = -z * MINSPERHOUR;
sp->ttis[1].tt_gmtoff = -z * MINSPERHOUR + SECSPERHOUR;
sp->ttis[0].tt_isdst = 0;
sp->ttis[1].tt_isdst = 1;
stoprule.r_type = MONTH_NTH_DAY_OF_WEEK;
stoprule.r_day = 0;
stoprule.r_week = 5;
stoprule.r_mon = 10;
stoprule.r_time = 2 * SECSPERHOUR;
startrule = stoprule;
startrule.r_mon = 4;
startrule.r_week = 1;
if (z >= -180 && z < 150) {
/* At this point we make a really gratuitous assumption: */
/* if the time zone could be Europe, we use the European */
/* Union rules without checking what country we're in. */
/* The AmigaDOS locale country codes do not, at least in */
/* 2.x versions of the OS, recognize very many countries */
/* outside of Europe and North America. */
sp->typecnt = 2;
startrule.r_mon = 3; /* one week earlier than US DST */
startrule.r_week = 5;
} else if (z >= 150 && z <= 480 &&
/* no DST in alaska, hawaii */
(ll->loc_CountryCode == 0x55534100 /*"USA"*/ ||
ll->loc_CountryCode == 0x43414E00 /*"CAN"*/))
sp->typecnt = 2;
/* We check the country code for U.S. or Canada because */
/* most of Latin America has no DST. Even in these two */
/* countries there are some exceptions... */
/* else if... Feel free to add more cases here! */
if (sp->typecnt > 1)
(*fill_tzstate_from_rules)(sp, &startrule, &stoprule);
}
CloseLocale(ll);
}
CloseLibrary(LocaleBase);
}
me->pr_WindowPtr = old_window;
return valid;
}
#ifdef ZIP
time_t time(time_t *tp)
( run in 1.607 second using v1.01-cache-2.11-cpan-2aafcb1aa8b )