• Date format setting or system toggle options

    From Nightfox@VERT/DIGDIST to All on Wednesday, July 30, 2014 20:10:43
    Hi all,

    In Synchronet JavaScript, does anyone know if there's a way to get the setting for whether to use European date format (as under SCFG > System > Toggle Options > European Date Format (DD/MM/YY))? I've checked in the Synchronet JavaScript Object Model Reference but I'm not seeing where that might be available in JavaScript:
    http://www.synchro.net/docs/jsobjs.html

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From echicken@VERT/ECBBS to Nightfox on Thursday, July 31, 2014 01:24:25
    Re: Date format setting or system toggle options
    By: Nightfox to All on Wed Jul 30 2014 20:10:43

    In Synchronet JavaScript, does anyone know if there's a way to get the setting for whether to use European date format (as under SCFG > System > Toggle Options > European Date Format (DD/MM/YY))? I've checked in the Synchronet JavaScript Object Model Reference but I'm not seeing where that

    I don't think that setting is exposed to the JS environment, however the
    output of the system.datestr method is dictated by it.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Nightfox@VERT/DIGDIST to echicken on Thursday, July 31, 2014 07:36:22
    Re: Date format setting or system toggle options
    By: echicken to Nightfox on Thu Jul 31 2014 01:24:25

    In Synchronet JavaScript, does anyone know if there's a way to get
    the setting for whether to use European date format (as under SCFG >

    I don't think that setting is exposed to the JS environment, however the output of the system.datestr method is dictated by it.

    Thanks. Maybe there is a way to figure out the date format being used with that.. I'll have to look into that.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From echicken@VERT/ECBBS to Nightfox on Thursday, July 31, 2014 11:02:30
    Re: Date format setting or system toggle options
    By: Nightfox to echicken on Thu Jul 31 2014 07:36:22

    Thanks. Maybe there is a way to figure out the date format being used with that.. I'll have to look into that.

    Probably something like:

    if(strftime("%d/%m/%y") == system.datestr()) {
    // Format in use is dd/mm/yy
    } else {
    // Format in use is mm/dd/yy
    }

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From echicken@VERT/ECBBS to Nightfox on Thursday, July 31, 2014 13:17:37
    Re: Date format setting or system toggle options
    By: echicken to Nightfox on Thu Jul 31 2014 11:02:30

    if(strftime("%d/%m/%y") == system.datestr()) {
    // Format in use is dd/mm/yy
    } else {
    // Format in use is mm/dd/yy
    }

    Or perhaps better:

    var t = time();
    var dmy = (strftime("%d/%m/%y", t) == system.datestr(t)) ? true : false;

    Which is probably overly cautious, and you could just do:

    var dmy = (strftime("%d/%m/%y") == system.datestr()) ? true : false;

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Nightfox@VERT/DIGDIST to echicken on Thursday, July 31, 2014 19:56:10
    Re: Date format setting or system toggle options
    By: echicken to Nightfox on Thu Jul 31 2014 13:17:37

    Or perhaps better:

    var t = time();
    var dmy = (strftime("%d/%m/%y", t) == system.datestr(t)) ? true : false;

    Which is probably overly cautious, and you could just do:

    var dmy = (strftime("%d/%m/%y") == system.datestr()) ? true : false;

    Thanks. :)

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Nightfox@VERT/DIGDIST to echicken on Thursday, July 31, 2014 19:58:08
    Re: Date format setting or system toggle options
    By: Nightfox to echicken on Thu Jul 31 2014 19:56:10

    var t = time();
    var dmy = (strftime("%d/%m/%y", t) == system.datestr(t)) ? true :
    false;

    Thanks. :)

    By the way, the ? true : false is redundant. This should be enough to get a boolean value:
    var dmy = (strftime("%d/%m/%y", t) == system.datestr(t));

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From echicken@VERT/ECBBS to Nightfox on Thursday, July 31, 2014 23:25:16
    Re: Date format setting or system toggle options
    By: Nightfox to echicken on Thu Jul 31 2014 19:58:08

    By the way, the ? true : false is redundant. This should be enough to get a boolean value:
    var dmy = (strftime("%d/%m/%y", t) == system.datestr(t));

    Indeed - didn't really give it a ton of thought (I don't normally use the shorthand if ... else in quite that way.)

    I'm trying to guess at why you want to determine the value of this setting in the first place - figuring out how to format a field label or column heading?

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Nightfox@VERT/DIGDIST to echicken on Friday, August 01, 2014 07:15:44
    Re: Date format setting or system toggle options
    By: echicken to Nightfox on Thu Jul 31 2014 23:25:16

    I'm trying to guess at why you want to determine the value of this
    setting in the first place - figuring out how to format a field label or column heading?

    Yeah, I had an idea for a custom new user application script for ANSI users that would use more of a full-screen lightbar interface, and I wanted to display the date format for the birthday.
    In general, it would be useful to know the configured date format for other instances where you'd want to format a date for a label or column heading. I have a message lister mod that I wrote that has a date header that this might be useful for.. Not sure yet if I want to update it to detect the system date format or leave it to use the YYYY-MM-DD format..

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Deuce@VERT/SYNCNIX to echicken on Monday, August 11, 2014 21:20:51
    Re: Date format setting or system toggle options
    By: echicken to Nightfox on Thu Jul 31 2014 11:02 am

    Probably something like:

    if(strftime("%d/%m/%y") == system.datestr()) {
    // Format in use is dd/mm/yy
    } else {
    // Format in use is mm/dd/yy
    }

    Better off using a known time value to avoid misdetection when the day is the same as the month. system.datestr() can take a time_t value, so use constants:

    if (system.datestr(1407817211) == "08/11/14")...

    Adjust for your timezone as needed.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Deuce@VERT/SYNCNIX to echicken on Monday, August 11, 2014 21:23:03
    Re: Date format setting or system toggle options
    By: Deuce to echicken on Mon Aug 11 2014 09:20 pm

    Better off using a known time value to avoid misdetection when the day is the same as the month. system.datestr() can take a time_t value, so use constants:

    Ah, it is available...

    load("sbbsdefs.js");
    if (system.setting & SYS_EURODATE)...


    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From echicken@VERT/ECBBS to Deuce on Tuesday, August 12, 2014 13:11:42
    Re: Date format setting or system toggle options
    By: Deuce to echicken on Mon Aug 11 2014 21:23:03

    load("sbbsdefs.js");
    if (system.setting & SYS_EURODATE)...

    Did not know about that one. Certainly makes it easier.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Nightfox@VERT/DIGDIST to Deuce on Tuesday, August 12, 2014 20:21:14
    Re: Date format setting or system toggle options
    By: Deuce to echicken on Mon Aug 11 2014 21:23:03

    Ah, it is available...

    load("sbbsdefs.js");
    if (system.setting & SYS_EURODATE)...

    Do you mean system.settings ('s' at the end)? I see that mentioned in the Synchronet JavaScript docs:
    www.synchro.net/docs/jsobjs.html#system
    Also, that documentation page says to see SS_* in sbbsdefs.js for bit definitions; in sbbsdefs.js, there is a comment that says SS_* are for bbs.sys_status and the SYS_* settings are for system.settings - So I'm wondering if that documentation page needs to be updated?

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Deuce@VERT/SYNCNIX to Nightfox on Wednesday, August 13, 2014 02:27:52
    Re: Date format setting or system toggle options
    By: Nightfox to Deuce on Tue Aug 12 2014 08:21 pm

    Do you mean system.settings ('s' at the end)? I see that mentioned in the Synchronet JavaScript docs:
    www.synchro.net/docs/jsobjs.html#system
    Also, that documentation page says to see SS_* in sbbsdefs.js for bit definitions; in sbbsdefs.js, there is a comment that says SS_* are for bbs.sys_status and the SYS_* settings are for system.settings - So I'm wondering if that documentation page needs to be updated?

    Yep and yep.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)