AmendHub

Download:

jcs

/

subtext

/

amendments

/

398

session: Add "timezone" template variable


jcs made amendment 398 about 1 year ago
--- GUIDE Wed Nov 30 14:06:26 2022 +++ GUIDE Sat Mar 11 20:52:56 2023 @@ -81,17 +81,19 @@ Supported variables: - {{#}} Stops varible expansion for the rest of the template. Useful when printing untrusted data (mostly used internally). + - {{new_mail}} + If the user has any new, unread mail messages, the count such as + "(4 New)". Otherwise it is blank. - {{node}} The current node, such as "ttyt0". - {{phone_number}} The system's configured phone number, such as "(312) 555-1212". - {{time}} The current system time in 24-hour format, such as "23:59". + - {{timezone}} + The system's configured "Timezone (Abbrev)". - {{username}} The currently logged-in user's username, or "guest". - - {{new_mail}} - If the user has any new, unread mail messages, the count such as - "(4 New)". Otherwise it is blank. - {{"string"}} Print the literal string "string". This is useful in conditionals. --- session.c Fri Mar 10 16:48:59 2023 +++ session.c Sat Mar 11 13:47:20 2023 @@ -1305,6 +1305,8 @@ session_expand_var(struct session *session, char *ivar } else if (strcmp(var, "time") == 0) { now = localtime((time_t *)&Time); retlen = strftime(retval, retsize, "%H:%M", now); + } else if (strcmp(var, "timezone") == 0) { + retlen = strlcpy(retval, db->config.timezone, retsize); } else if (strcmp(var, "username") == 0) { retlen = strlcpy(retval, session->user ? session->user->username : GUEST_USERNAME, retsize);