Skip to content
Snippets Groups Projects
Commit 6200bc13 authored by nightfox's avatar nightfox
Browse files

Fixed a bug related to adjusting message dates to the local BBS time zone

parent 028f4dac
No related branches found
No related tags found
No related merge requests found
...@@ -214,8 +214,8 @@ if (system.version_num < 31500) ...@@ -214,8 +214,8 @@ if (system.version_num < 31500)
} }
   
// Reader version information // Reader version information
var READER_VERSION = "1.10 Beta 6"; var READER_VERSION = "1.10 Beta 7";
var READER_DATE = "2016-02-14"; var READER_DATE = "2016-02-15";
   
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
...@@ -1092,10 +1092,15 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1092,10 +1092,15 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
this.enhMsgHeaderLines.push(hdrLine5); this.enhMsgHeaderLines.push(hdrLine5);
var hdrLine6 = "\1n\1c" + VERTICAL_SINGLE + "\1h\1k" + BLOCK1 + BLOCK2 + BLOCK3 var hdrLine6 = "\1n\1c" + VERTICAL_SINGLE + "\1h\1k" + BLOCK1 + BLOCK2 + BLOCK3
+ "\1gD\1n\1gate\1h\1c: \1b@MSG_DATE-L"; + "\1gD\1n\1gate\1h\1c: \1b@MSG_DATE-L";
numChars = console.screen_columns - 23; //numChars = console.screen_columns - 23;
numChars = console.screen_columns - 67;
for (var i = 0; i < numChars; ++i) for (var i = 0; i < numChars; ++i)
hdrLine6 += "#"; hdrLine6 += "#";
hdrLine6 += "@\1n\1c" + VERTICAL_SINGLE; //hdrLine6 += "@\1n\1c" + VERTICAL_SINGLE;
hdrLine6 += "@ @MSG_TIMEZONE@\1n";
for (var i = 0; i < 40; ++i)
hdrLine6 += " ";
hdrLine6 += "\1n\1c" + VERTICAL_SINGLE;
this.enhMsgHeaderLines.push(hdrLine6); this.enhMsgHeaderLines.push(hdrLine6);
var hdrLine7 = "\1n\1h\1c" + BOTTOM_T_SINGLE + HORIZONTAL_SINGLE + "\1n\1c" var hdrLine7 = "\1n\1h\1c" + BOTTOM_T_SINGLE + HORIZONTAL_SINGLE + "\1n\1c"
+ HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\1h\1k"; + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\1h\1k";
...@@ -7496,7 +7501,7 @@ function DigDistMsgReader_DisplaySyncMsgHeader(pMsgHdr) ...@@ -7496,7 +7501,7 @@ function DigDistMsgReader_DisplaySyncMsgHeader(pMsgHdr)
// message read prompt, this script now has to parse & replace some of // message read prompt, this script now has to parse & replace some of
// the @-codes in the message header line, since Synchronet doesn't know // the @-codes in the message header line, since Synchronet doesn't know
// that the user is reading a message. // that the user is reading a message.
console.putmsg(this.ParseMsgAtCodes(fileLine, pMsgHdr, null, dateTimeStr, true)); console.putmsg(this.ParseMsgAtCodes(fileLine, pMsgHdr, null, dateTimeStr, false, true));
console.crlf(); console.crlf();
} }
msgHdrFile.close(); msgHdrFile.close();
...@@ -7908,15 +7913,27 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter ...@@ -7908,15 +7913,27 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter
// used. // used.
// pDateTimeStr: Optional formatted string containing the date & time. If this is // pDateTimeStr: Optional formatted string containing the date & time. If this is
// not provided, the current date & time will be used. // not provided, the current date & time will be used.
// pBBSLocalTimeZone: Optional boolean - Whether or not pDateTimeStr is in the BBS's
// local time zone. Defaults to false.
// pAllowCLS: Optional boolean - Whether or not to allow the @CLS@ code. // pAllowCLS: Optional boolean - Whether or not to allow the @CLS@ code.
// Defaults to false. // Defaults to false.
// //
// Return value: A string with the complex @-codes substituted in the line with the // Return value: A string with the complex @-codes substituted in the line with the
// appropriate message header information. // appropriate message header information.
function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pDateTimeStr, pAllowCLS) function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pDateTimeStr,
pBBSLocalTimeZone, pAllowCLS)
{ {
var textLine = pTextLine; var textLine = pTextLine;
var dateTimeStr = (typeof(pDateTimeStr) == "string" ? pDateTimeStr : strftime("%Y-%m-%d %H:%M:%S")); var dateTimeStr = "";
var useBBSLocalTimeZone = false;
if (typeof(pDateTimeStr) == "string")
{
dateTimeStr = pDateTimeStr;
if (typeof(pBBSLocalTimeZone) == "boolean")
useBBSLocalTimeZone = pBBSLocalTimeZone;
}
else
dateTimeStr = strftime("%Y-%m-%d %H:%M:%S", pMsgHdr.when_written_date);
// Message attribute strings // Message attribute strings
var allMsgAttrStr = makeAllMsgAttrStr(pMsgHdr); var allMsgAttrStr = makeAllMsgAttrStr(pMsgHdr);
var mainMsgAttrStr = makeMainMsgAttrStr(pMsgHdr.attr); var mainMsgAttrStr = makeMainMsgAttrStr(pMsgHdr.attr);
...@@ -7951,8 +7968,8 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD ...@@ -7951,8 +7968,8 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD
// In this case, the subject length is the length of the whole format specifier. // In this case, the subject length is the length of the whole format specifier.
var substLen = atCodeMatchArray[idx].length; var substLen = atCodeMatchArray[idx].length;
textLine = this.ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, textLine, substLen, textLine = this.ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, textLine, substLen,
atCodeMatchArray[idx], pDateTimeStr, mainMsgAttrStr, atCodeMatchArray[idx], pDateTimeStr, useBBSLocalTimeZone,
auxMsgAttrStr, netMsgAttrStr, allMsgAttrStr); mainMsgAttrStr, auxMsgAttrStr, netMsgAttrStr, allMsgAttrStr);
} }
} }
// Now, look for subject formatters with the length specified (i.e., @MSG_SUBJECT-L20@ or @MSG_SUBJECT-R20@) // Now, look for subject formatters with the length specified (i.e., @MSG_SUBJECT-L20@ or @MSG_SUBJECT-R20@)
...@@ -7966,8 +7983,8 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD ...@@ -7966,8 +7983,8 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD
var dashJustifyIndex = findDashJustifyIndex(atCodeMatchArray[idx]); var dashJustifyIndex = findDashJustifyIndex(atCodeMatchArray[idx]);
var substLen = atCodeMatchArray[idx].substring(dashJustifyIndex+2, atCodeMatchArray[idx].length-1); var substLen = atCodeMatchArray[idx].substring(dashJustifyIndex+2, atCodeMatchArray[idx].length-1);
textLine = this.ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, textLine, substLen, atCodeMatchArray[idx], textLine = this.ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, textLine, substLen, atCodeMatchArray[idx],
pDateTimeStr, mainMsgAttrStr, auxMsgAttrStr, netMsgAttrStr, pDateTimeStr, useBBSLocalTimeZone, mainMsgAttrStr, mainMsgAttrStr,
allMsgAttrStr, dashJustifyIndex); auxMsgAttrStr, netMsgAttrStr, allMsgAttrStr, dashJustifyIndex);
} }
} }
} }
...@@ -8021,7 +8038,7 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD ...@@ -8021,7 +8038,7 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD
.replace(/@MSG_REPLY_ID@/gi, (typeof(pMsgHdr["reply_id"]) == "string" ? pMsgHdr["reply_id"] : "")) .replace(/@MSG_REPLY_ID@/gi, (typeof(pMsgHdr["reply_id"]) == "string" ? pMsgHdr["reply_id"] : ""))
.replace(/@MSG_FROM_NET@/gi, (typeof(pMsgHdr["from_net_addr"]) == "string" ? pMsgHdr["from_net_addr"] : "")) .replace(/@MSG_FROM_NET@/gi, (typeof(pMsgHdr["from_net_addr"]) == "string" ? pMsgHdr["from_net_addr"] : ""))
.replace(/@MSG_TO_NET@/gi, (typeof(pMsgHdr["to_net_addr"]) == "string" ? pMsgHdr["to_net_addr"] : "")) .replace(/@MSG_TO_NET@/gi, (typeof(pMsgHdr["to_net_addr"]) == "string" ? pMsgHdr["to_net_addr"] : ""))
.replace(/@MSG_TIMEZONE@/gi, system.zonestr(pMsgHdr["when_written_zone"])) .replace(/@MSG_TIMEZONE@/gi, (useBBSLocalTimeZone ? system.zonestr(system.timezone) : system.zonestr(pMsgHdr["when_written_zone"])))
.replace(/@GRP@/gi, groupName) .replace(/@GRP@/gi, groupName)
.replace(/@GRPL@/gi, groupDesc) .replace(/@GRPL@/gi, groupDesc)
.replace(/@SUB@/gi, subName) .replace(/@SUB@/gi, subName)
...@@ -8055,14 +8072,15 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD ...@@ -8055,14 +8072,15 @@ function DigDistMsgReader_ParseMsgAtCodes(pTextLine, pMsgHdr, pDisplayMsgNum, pD
// pSpecifiedLen: The length extracted from the @-code format string // pSpecifiedLen: The length extracted from the @-code format string
// pAtCodeStr: The @-code format string, which will be replaced with the actual message info // pAtCodeStr: The @-code format string, which will be replaced with the actual message info
// pDateTimeStr: Formatted string containing the date & time // pDateTimeStr: Formatted string containing the date & time
// pUseBBSLocalTimeZone: Boolean - Whether or not pDateTimeStr is in the BBS's local time zone.
// pMsgMainAttrStr: A string describing the main message attributes ('attr' property of header) // pMsgMainAttrStr: A string describing the main message attributes ('attr' property of header)
// pMsgAuxAttrStr: A string describing the auxiliary message attributes ('auxattr' property of header) // pMsgAuxAttrStr: A string describing the auxiliary message attributes ('auxattr' property of header)
// pMsgNetAttrStr: A string describing the network message attributes ('netattr' property of header) // pMsgNetAttrStr: A string describing the network message attributes ('netattr' property of header)
// pMsgAllAttrStr: A string describing all message attributes // pMsgAllAttrStr: A string describing all message attributes
// pDashJustifyIdx: Optional - The index of the -L or -R in the @-code string // pDashJustifyIdx: Optional - The index of the -L or -R in the @-code string
function DigDistMsgReader_ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, pTextLine, pSpecifiedLen, pAtCodeStr, pDateTimeStr, function DigDistMsgReader_ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, pTextLine, pSpecifiedLen,
pMsgMainAttrStr, pMsgAuxAttrStr, pMsgNetAttrStr, pMsgAllAttrStr, pAtCodeStr, pDateTimeStr, pUseBBSLocalTimeZone, pMsgMainAttrStr, pMsgAuxAttrStr,
pDashJustifyIdx) pMsgNetAttrStr, pMsgAllAttrStr, pDashJustifyIdx)
{ {
if (typeof(pDashJustifyIdx) != "number") if (typeof(pDashJustifyIdx) != "number")
pDashJustifyIdx = findDashJustifyIndex(pAtCodeStr); pDashJustifyIdx = findDashJustifyIndex(pAtCodeStr);
...@@ -8106,7 +8124,12 @@ function DigDistMsgReader_ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, pTe ...@@ -8106,7 +8124,12 @@ function DigDistMsgReader_ReplaceMsgAtCodeFormatStr(pMsgHdr, pDisplayMsgNum, pTe
else if (pAtCodeStr.indexOf("@MSG_REPLY_ID") > -1) else if (pAtCodeStr.indexOf("@MSG_REPLY_ID") > -1)
replacementTxt = (typeof pMsgHdr["reply_id"] === "undefined" ? "" : pMsgHdr["reply_id"].substr(0, pSpecifiedLen)); replacementTxt = (typeof pMsgHdr["reply_id"] === "undefined" ? "" : pMsgHdr["reply_id"].substr(0, pSpecifiedLen));
else if (pAtCodeStr.indexOf("@MSG_TIMEZONE") > -1) else if (pAtCodeStr.indexOf("@MSG_TIMEZONE") > -1)
replacementTxt = system.zonestr(pMsgHdr["when_written_zone"]).substr(0, pSpecifiedLen); {
if (pUseBBSLocalTimeZone)
replacementTxt = system.zonestr(system.timezone).substr(0, pSpecifiedLen);
else
replacementTxt = system.zonestr(pMsgHdr["when_written_zone"]).substr(0, pSpecifiedLen);
}
else if (pAtCodeStr.indexOf("@GRP") > -1) else if (pAtCodeStr.indexOf("@GRP") > -1)
{ {
if (this.readingPersonalEmail) if (this.readingPersonalEmail)
...@@ -8816,9 +8839,18 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS ...@@ -8816,9 +8839,18 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS
if ((this.enhMsgHeaderLines.length == 0) || (this.enhMsgHeaderWidth == 0)) if ((this.enhMsgHeaderLines.length == 0) || (this.enhMsgHeaderWidth == 0))
return; return;
   
// Create a formatted date & time string and a string describing the // Create a formatted date & time string. Adjust the message's time to
// message attributes // the BBS local time zone if possible.
var dateTimeStr = pMsgHdr["date"].replace(/ [-+][0-9]+$/, ""); var dateTimeStr = "";
var msgWrittenLocalTime = msgWrittenTimeToLocalBBSTime(pMsgHdr);
var useBBSLocalTimeZone = false;
if (msgWrittenLocalTime != -1)
{
dateTimeStr = strftime("%a, %d %b %Y %H:%M:%S", msgWrittenLocalTime);
useBBSLocalTimeZone = true;
}
else
dateTimeStr = pMsgHdr["date"].replace(/ [-+][0-9]+$/, "");
   
// If the user's terminal supports ANSI, we can move the cursor and // If the user's terminal supports ANSI, we can move the cursor and
// display the header where specified. // display the header where specified.
...@@ -8831,7 +8863,7 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS ...@@ -8831,7 +8863,7 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS
{ {
console.gotoxy(screenX, screenY++); console.gotoxy(screenX, screenY++);
console.putmsg(this.ParseMsgAtCodes(this.enhMsgHeaderLines[hdrFileIdx], pMsgHdr, console.putmsg(this.ParseMsgAtCodes(this.enhMsgHeaderLines[hdrFileIdx], pMsgHdr,
pDisplayMsgNum, dateTimeStr, false)); pDisplayMsgNum, dateTimeStr, useBBSLocalTimeZone, false));
} }
// Older - Used to center the header lines, but I'm not sure this is necessary, // Older - Used to center the header lines, but I'm not sure this is necessary,
// and it might even make the header off by one, which could be bad. // and it might even make the header off by one, which could be bad.
...@@ -8852,7 +8884,7 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS ...@@ -8852,7 +8884,7 @@ function DigDistMsgReader_DisplayEnhancedMsgHdr(pMsgHdr, pDisplayMsgNum, pStartS
for (var hdrFileIdx = 0; hdrFileIdx < this.enhMsgHeaderLines.length; ++hdrFileIdx) for (var hdrFileIdx = 0; hdrFileIdx < this.enhMsgHeaderLines.length; ++hdrFileIdx)
{ {
console.putmsg(this.ParseMsgAtCodes(this.enhMsgHeaderLines[hdrFileIdx], pMsgHdr, console.putmsg(this.ParseMsgAtCodes(this.enhMsgHeaderLines[hdrFileIdx], pMsgHdr,
pDisplayMsgNum, dateTimeStr, false)); pDisplayMsgNum, dateTimeStr, useBBSLocalTimeZone, false));
} }
} }
} }
...@@ -16530,10 +16562,10 @@ function getStrAfterPeriod(pStr) ...@@ -16530,10 +16562,10 @@ function getStrAfterPeriod(pStr)
// when_written_zone property, then this function will return -1. // when_written_zone property, then this function will return -1.
function msgWrittenTimeToLocalBBSTime(pMsgHdr) function msgWrittenTimeToLocalBBSTime(pMsgHdr)
{ {
if (!pMsgHdr.hasOwnProperty("when_written_time") || !pMsgHdr.hasOwnProperty("when_written_zone")) if (!pMsgHdr.hasOwnProperty("when_written_time") || !pMsgHdr.hasOwnProperty("when_written_zone_offset") || !pMsgHdr.hasOwnProperty("when_imported_zone_offset"))
return -1; return -1;
   
var timeZoneDiffMinutes = msgHeader.when_imported_zone_offset - msgHeader.when_written_zone_offset; var timeZoneDiffMinutes = pMsgHdr.when_imported_zone_offset - pMsgHdr.when_written_zone_offset;
//var timeZoneDiffMinutes = pMsgHdr.when_written_zone - system.timezone; //var timeZoneDiffMinutes = pMsgHdr.when_written_zone - system.timezone;
var timeZoneDiffSeconds = timeZoneDiffMinutes * 60; var timeZoneDiffSeconds = timeZoneDiffMinutes * 60;
var msgWrittenTimeAdjusted = pMsgHdr.when_written_time + timeZoneDiffSeconds; var msgWrittenTimeAdjusted = pMsgHdr.when_written_time + timeZoneDiffSeconds;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment