Skip to content

Commit

Permalink
ARPA date: Use new macro BBSUTCZONE to eliminate hardcoded timezones.
Browse files Browse the repository at this point in the history
  • Loading branch information
IepIweidieng committed Feb 13, 2020
1 parent 934f407 commit 5a131c7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ execute_process(
)
LOADVALUE(BBSHOME "${BBSUSR_HOME}" ${BBSCONF_ORIGIN} BBSHOME)

## Numeric local timezone
execute_process(
COMMAND date %z
OUTPUT_VARIABLE BBSUTCZONE_DEFAULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
LOADVALUE(BBSUTCZONE "${BBSUTCZONE_DEFAULT}" ${BBSCONF_ORIGIN} BBSUTCZONE)

# Flags for enabling modules
DEF_TEST(M3_USE_PMORE ${BBSCONF} USE_PMORE)
DEF_TEST(M3_USE_PFTERM ${BBSCONF} USE_PFTERM)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export:
@$(EXPORTVAR$(exconf::= BBSGID))
@$(EXPORTVAR$(exconf::= WWWGID))
@$(EXPORTCONF$(exconf::= BBSHOME)$(exvalue::= \"$(BBSHOME)\"))
@$(EXPORTCONF$(exconf::= BBSUTCZONE)$(exvalue::= \"$(BBSUTCZONE)\"))
@$("$(ARCHI)" == "64" :? $(EXPORTCONF$(exconf::= _FILE_OFFSET_BITS)$(exvalue::= 64)) :)

configure:
Expand Down
3 changes: 3 additions & 0 deletions dreambbs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ BBSVER != $(GETVALUE$(conf::= "BBSVER_SUFFIX")$(default::= "")$(hdr::= $(BBSCONF
BBSUSR_HOME != getent passwd $(BBSUSR) | cut -d: -f6
BBSHOME != $(GETVAR$(var::= "$(BBSHOME)")$(else_var::= $(GETVALUE$(conf::= "BBSHOME")$(default::= "$(BBSUSR_HOME)")$(hdr::= $(BBSCONF)))))

## Numeric local timezone
BBSUTCZONE != $(GETVAR$(var::= "$(BBSUTCZONE)")$(else_var::= $(GETVALUE$(conf::= "BBSUTCZONE")$(default::= "$(:!date +%z!)")$(hdr::= $(BBSCONF)))))

# rules ref: PttBBS: mbbsd/Makefile
DEF_LIST != sh -c '$(GETCONFS$(hdr::= $(BBSCONF)))'
DEF_TEST = [ $(DEF_LIST:M$(conf:M*:S/"//g:N")) ] # Balance the quotes
Expand Down
2 changes: 2 additions & 0 deletions innbbsd/innbbsconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#define INNBBS_PORT (7777)

#define INNBBS_UTCZONE BBSUTCZONE /* Numeric local timezone */

/* ----------------------------------------------------- */
/* innbbsd 的設定 */
/* ----------------------------------------------------- */
Expand Down
6 changes: 5 additions & 1 deletion innbbsd/rec_article.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ static void
zone += strcspn(zone, "+-"); /* Seek `'+'` or `'-'` */
if (*zone)
datevalue -= ((*zone == '-') ? -1 : 1) * ((strtol(zone+1, NULL, 10) / 100) * 3600 + (strtol(zone+1, NULL, 10) % 100) * 60);
datevalue += 28800; /* 台灣所在的 CST 時區比 GMT 快八小時 */
/* Convert it to the local timezone */
zone = INNBBS_UTCZONE;
zone += strcspn(zone, "+-"); /* Seek `'+'` or `'-'` */
if (*zone)
datevalue += ((*zone == '-') ? -1 : 1) * ((strtol(zone+1, NULL, 10) / 100) * 3600 + (strtol(zone+1, NULL, 10) % 100) * 60);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion lib/date_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ char *Etime(const time_t * clock)
/* ARPANET format: Thu, 11 Feb 1999 06:00:37 +0800 */
/* strftime(datemsg, 40, "%a, %d %b %Y %T %Z", localtime(clock)); */
/* Thor.990125: time zone的傳回值不知和ARPANET格式是否一樣, 先硬給, 同sendmail */
strftime(datemsg, 40, "%a, %d %b %Y %T +0800", localtime(clock));
strftime(datemsg, 40, "%a, %d %b %Y %T " BBSUTCZONE, localtime(clock));
return (datemsg);
}

Expand Down
2 changes: 2 additions & 0 deletions make_export.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
#define WWWGID @WWWGID@
#undef BBSHOME
#define BBSHOME "@BBSHOME@"
#undef BBSUTCZONE
#define BBSUTCZONE "@BBSUTCZONE@"
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@

0 comments on commit 5a131c7

Please sign in to comment.