Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I put aside my copy of "BOWLING WORLD" and think about GUN CONTROL legislation...


dovenet / Synchronet Javascript / Run JS with a different TZ

SubjectAuthor
* Run JS with a different TZnelgin
`* Run JS with a different TZDigital Man
 `* Run JS with a different TZnelgin
  `* Run JS with a different TZDigital Man
   `* Run JS with a different TZnelgin
    `* Run JS with a different TZDigital Man
     `* Run JS with a different TZnelgin
      `* Run JS with a different TZDigital Man
       `* Run JS with a different TZnelgin
        +* Run JS with a different TZDigital Man
        |`- Run JS with a different TZnelgin
        `* Run JS with a different TZCharles Blackburn
         `* Run JS with a different TZnelgin
          +* Run JS with a different TZCharles Blackburn
          |`* Run JS with a different TZnelgin
          | `- Run JS with a different TZCharles Blackburn
          `- Run JS with a different TZMRO

1
Run JS with a different TZ

<65283AF4.1425.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=91&group=DOVE-Net.Synchronet_Javascript#91

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: All
Subject: Run JS with a different TZ
Message-ID: <65283AF4.1425.dove-syncjs@endofthelinebbs.com>
Date: Thu, 12 Oct 2023 13:29:08 -0500
X-Comment-To: All
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231012113634-0700 c1e0
WhenExported: 20231012151311-0700 c1e0
ExportedFrom: VERT sync-js 3932
WhenImported: 20231012132908-0500 c168
WhenExported: 20231012133638-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1425
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Thu, 12 Oct 2023 18:29 UTC

I have a script that I want to run using a different timezone. My system is America/Chicago and I want users to run it from the xtrn section as America/New_York.

My original ideas was to create a bash wrapper script to set TZ and call jsexec but wont work since it requires various bbs and console functions to work properly.

Also, javascript doesn't appear to let you set an environment variable like you can with other languages such as perl.

Since I don't want to run my server or BBS in eastern time, does anyone have any suggestons on a workaround, other than to rewrtite it in perl? :)
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652842FB.3933.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=92&group=DOVE-Net.Synchronet_Javascript#92

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652842FB.3933.sync-js@vert.synchro.net>
Date: Thu, 12 Oct 2023 12:03:23 -0700
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <65283AF4.1425.dove-syncjs@endofthelinebbs.com>
References: <65283AF4.1425.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Linux master/69bc98557 Sep 25 2023 GCC 12.2.0
X-FTN-CHRS: CP437 2
WhenImported: 20231012120323-0700 c1e0
WhenExported: 20231012151311-0700 c1e0
ExportedFrom: VERT sync-js 3933
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Thu, 12 Oct 2023 19:03 UTC

Re: Run JS with a different TZ
By: nelgin to All on Thu Oct 12 2023 01:29 pm

> I have a script that I want to run using a different timezone. My system is
> America/Chicago and I want users to run it from the xtrn section as
> America/New_York.
>
>
> My original ideas was to create a bash wrapper script to set TZ and call
> jsexec but wont work since it requires various bbs and console functions to
> work properly.
>
> Also, javascript doesn't appear to let you set an environment variable like
> you can with other languages such as perl.
>
> Since I don't want to run my server or BBS in eastern time, does anyone have
> any suggestons on a workaround, other than to rewrtite it in perl? :)

How does your script use the timezone currently? Could that usage be updated to
allow you to control the timezone used at run time (e.g. with a command-line option)?
--
digital man (rob)

Synchronet "Real Fact" #59:
Synchronet swag used to be available for purchase at cafepress.com/synchronet
Norco, CA WX: 79.0°F, 24.0% humidity, 4 mph NW wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Run JS with a different TZ

<65297A43.1427.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=93&group=DOVE-Net.Synchronet_Javascript#93

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Digital Man
Subject: Run JS with a different TZ
Message-ID: <65297A43.1427.dove-syncjs@endofthelinebbs.com>
Date: Fri, 13 Oct 2023 12:11:31 -0500
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652842FB.3933.sync-js@vert.synchro.net>
References: <652842FB.3933.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231013102157-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3934
WhenImported: 20231013121131-0500 c168
WhenExported: 20231013122161-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1427
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Fri, 13 Oct 2023 17:11 UTC

Re: Run JS with a different TZ
By: Digital Man to nelgin on Thu Oct 12 2023 12:03:23

> How does your script use the timezone currently? Could that usage be updated
> to allow you to control the timezone used at run time (e.g. with a
> command-line option)?

The only way I can find to get it the script to use a different timezone is to set the TZ variable before it is executed, at least while testing with jsexec.

Since I will have to call it using ?script.js to make use of the bbs and console functions and properties, I'm not exactly sure how that would work.
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652983AF.3935.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=94&group=DOVE-Net.Synchronet_Javascript#94

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652983AF.3935.sync-js@vert.synchro.net>
Date: Fri, 13 Oct 2023 10:51:43 -0700
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <65297A43.1427.dove-syncjs@endofthelinebbs.com>
References: <65297A43.1427.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Win32 master/a47e13327 Sep 26 2023 MSC 1916
X-FTN-CHRS: CP437 2
WhenImported: 20231013105143-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3935
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Fri, 13 Oct 2023 17:51 UTC

Re: Run JS with a different TZ
By: nelgin to Digital Man on Fri Oct 13 2023 12:11 pm

> Re: Run JS with a different TZ
> By: Digital Man to nelgin on Thu Oct 12 2023 12:03:23
>
> > How does your script use the timezone currently? Could that usage be
> > updated to allow you to control the timezone used at run time (e.g. with
> > a command-line option)?
>
> The only way I can find to get it the script to use a different timezone is
> to set the TZ variable before it is executed, at least while testing with
> jsexec.
>
> Since I will have to call it using ?script.js to make use of the bbs and
> console functions and properties, I'm not exactly sure how that would work.

That didn't really answer my question: How is your script using the timezone currently?
--
digital man (rob)

Synchronet/BBS Terminology Definition #88:
UDP = User Datagram Protocol
Norco, CA WX: 70.1°F, 59.0% humidity, 0 mph SE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Run JS with a different TZ

<652990C8.1429.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=95&group=DOVE-Net.Synchronet_Javascript#95

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Digital Man
Subject: Run JS with a different TZ
Message-ID: <652990C8.1429.dove-syncjs@endofthelinebbs.com>
Date: Fri, 13 Oct 2023 13:47:36 -0500
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652983AF.3935.sync-js@vert.synchro.net>
References: <652983AF.3935.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231013115157-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3936
WhenImported: 20231013134736-0500 c168
WhenExported: 20231013135158-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1429
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Fri, 13 Oct 2023 18:47 UTC

Re: Run JS with a different TZ
By: Digital Man to nelgin on Fri Oct 13 2023 10:51:43

> That didn't really answer my question: How is your script using the timezone
> currently?

Oh, I'm reading a JSON file which has an ISO 8601 format date, then I'm passing that to something like d = new Date(isoDate); to create a date object so I can extract the time easier, I think I use strftime to get HH:MMa/p but, of course, the time I get is in central and not eastern. I can't just subtract an hour because that's not going to work during DST changes.

I hate to use something like moment-timezone for something like that, but it might be my only option unless you can think of something, I'm at a loss.
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<65299651.3937.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=96&group=DOVE-Net.Synchronet_Javascript#96

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <65299651.3937.sync-js@vert.synchro.net>
Date: Fri, 13 Oct 2023 12:11:13 -0700
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652990C8.1429.dove-syncjs@endofthelinebbs.com>
References: <652990C8.1429.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Win32 master/a47e13327 Sep 26 2023 MSC 1916
X-FTN-CHRS: CP437 2
WhenImported: 20231013121113-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3937
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Fri, 13 Oct 2023 19:11 UTC

Re: Run JS with a different TZ
By: nelgin to Digital Man on Fri Oct 13 2023 01:47 pm

> Re: Run JS with a different TZ
> By: Digital Man to nelgin on Fri Oct 13 2023 10:51:43
>
> > That didn't really answer my question: How is your script using the
> > timezone currently?
>
> Oh, I'm reading a JSON file which has an ISO 8601 format date, then I'm
> passing that to something like d = new Date(isoDate); to create a date
> object so I can extract the time easier, I think I use strftime to get
> HH:MMa/p but, of course, the time I get is in central and not eastern. I
> can't just subtract an hour because that's not going to work during DST
> changes.
>
> I hate to use something like moment-timezone for something like that, but it
> might be my only option unless you can think of something, I'm at a loss.

Does the ISO 8601 formatted date include the UTC offset?
--
digital man (rob)

Synchronet/BBS Terminology Definition #9:
BPS = Bits Per Second
Norco, CA WX: 75.9°F, 45.0% humidity, 0 mph SE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Run JS with a different TZ

<65299DBC.1431.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=97&group=DOVE-Net.Synchronet_Javascript#97

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Digital Man
Subject: Run JS with a different TZ
Message-ID: <65299DBC.1431.dove-syncjs@endofthelinebbs.com>
Date: Fri, 13 Oct 2023 14:42:52 -0500
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <65299651.3937.sync-js@vert.synchro.net>
References: <65299651.3937.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231013125338-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3938
WhenImported: 20231013144252-0500 c168
WhenExported: 20231013145162-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1431
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Fri, 13 Oct 2023 19:42 UTC

Re: Run JS with a different TZ
By: Digital Man to nelgin on Fri Oct 13 2023 12:11:13

> Does the ISO 8601 formatted date include the UTC offset?

This is an example of what I get, so the time is in UTC.

2023-10-13T23:30:00Z
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<6529A982.3939.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=98&group=DOVE-Net.Synchronet_Javascript#98

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <6529A982.3939.sync-js@vert.synchro.net>
Date: Fri, 13 Oct 2023 13:33:06 -0700
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <65299DBC.1431.dove-syncjs@endofthelinebbs.com>
References: <65299DBC.1431.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Win32 master/a47e13327 Sep 26 2023 MSC 1916
X-FTN-CHRS: CP437 2
WhenImported: 20231013133306-0700 c1e0
WhenExported: 20231013151315-0700 c1e0
ExportedFrom: VERT sync-js 3939
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Fri, 13 Oct 2023 20:33 UTC

Re: Run JS with a different TZ
By: nelgin to Digital Man on Fri Oct 13 2023 02:42 pm

> Re: Run JS with a different TZ
> By: Digital Man to nelgin on Fri Oct 13 2023 12:11:13
>
> > Does the ISO 8601 formatted date include the UTC offset?
>
> This is an example of what I get, so the time is in UTC.
>
> 2023-10-13T23:30:00Z

Okay, so if it's in UTC, it's in central *or* eastern US. It's UTC.

Example:
jsexec '-r Date("2023-10-13T23:30:00Z")'

when run on my system (in PDT), produces:
Result (string): Fri Oct 13 2023 13:30:31 GMT-0700 (PDT)
--
digital man (rob)

Rush quote #75:
Though his mind is not for rent, don't put him down as arrogant .. Tom Sawyer
Norco, CA WX: 80.5°F, 28.0% humidity, 0 mph E wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Run JS with a different TZ

<6529D976.1433.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=99&group=DOVE-Net.Synchronet_Javascript#99

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Digital Man
Subject: Run JS with a different TZ
Message-ID: <6529D976.1433.dove-syncjs@endofthelinebbs.com>
Date: Fri, 13 Oct 2023 18:57:42 -0500
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <6529A982.3939.sync-js@vert.synchro.net>
References: <6529A982.3939.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231013165814-0700 c1e0
WhenExported: 20231013211309-0700 c1e0
ExportedFrom: VERT sync-js 3940
WhenImported: 20231013185742-0500 c168
WhenExported: 20231013185820-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1433
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Fri, 13 Oct 2023 23:57 UTC

Re: Run JS with a different TZ
By: Digital Man to nelgin on Fri Oct 13 2023 13:33:06

> Okay, so if it's in UTC, it's in central *or* eastern US. It's UTC.
>
> Example:
> jsexec '-r Date("2023-10-13T23:30:00Z")'

jsexec '-r Date("2023-10-13T23:30:00Z")'
Result (string): Fri Oct 13 2023 18:54:33 GMT-0500 (CDT)

Right, which gives a result in central time. I want the result in eastern time, as per:

TZ="America/New_York" jsexec '-r Date("2023-10-13T23:30:00Z")'
Result (string): Fri Oct 13 2023 19:55:42 GMT-0400 (EDT)

However, there's no way to set TZ before executing the script from the xtrn section since I'm not calling jsexec.
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652A13AD.3941.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=100&group=DOVE-Net.Synchronet_Javascript#100

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652A13AD.3941.sync-js@vert.synchro.net>
Date: Fri, 13 Oct 2023 21:06:05 -0700
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <6529D976.1433.dove-syncjs@endofthelinebbs.com>
References: <6529D976.1433.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Win32 master/a47e13327 Sep 26 2023 MSC 1916
X-FTN-CHRS: CP437 2
WhenImported: 20231013210605-0700 c1e0
WhenExported: 20231013211309-0700 c1e0
ExportedFrom: VERT sync-js 3941
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Sat, 14 Oct 2023 04:06 UTC

Re: Run JS with a different TZ
By: nelgin to Digital Man on Fri Oct 13 2023 06:57 pm

> Re: Run JS with a different TZ
> By: Digital Man to nelgin on Fri Oct 13 2023 13:33:06
>
> > Okay, so if it's in UTC, it's in central *or* eastern US. It's UTC.
>
> > Example:
> > jsexec '-r Date("2023-10-13T23:30:00Z")'
>
> jsexec '-r Date("2023-10-13T23:30:00Z")'
> Result (string): Fri Oct 13 2023 18:54:33 GMT-0500 (CDT)
>
> Right, which gives a result in central time. I want the result in eastern
> time, as per:
>
> TZ="America/New_York" jsexec '-r Date("2023-10-13T23:30:00Z")'
> Result (string): Fri Oct 13 2023 19:55:42 GMT-0400 (EDT)
>
> However, there's no way to set TZ before executing the script from the xtrn
> section since I'm not calling jsexec.

Right. And environment variables are shared among on threads (e.g. nodes) of the sbbs instance, so even if you could set the TZ environment variable, you'd be changing for all threads. Likely not what you want.

There's a whole new JS Date thing in the works for some future version of JavaScript, but that'll be aways away from being integrated with sbbs.

I think the easiest thing to do would be to adjust the UTC value based on the UTC offset for central time (yeah, it'll change with DST) and then use Date.toUTCString() to convert it to a string.
--
digital man (rob)

Rush quote #87:
Shifting shafts of shining weave the fabric of their dreams .. Jacob's Ladder
Norco, CA WX: 66.1°F, 75.0% humidity, 0 mph SSW wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Run JS with a different TZ

<652A37A6.1435.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=101&group=DOVE-Net.Synchronet_Javascript#101

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Digital Man
Subject: Run JS with a different TZ
Message-ID: <652A37A6.1435.dove-syncjs@endofthelinebbs.com>
Date: Sat, 14 Oct 2023 01:39:34 -0500
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652A13AD.3941.sync-js@vert.synchro.net>
References: <652A13AD.3941.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231013234316-0700 c1e0
WhenExported: 20231014031312-0700 c1e0
ExportedFrom: VERT sync-js 3942
WhenImported: 20231014013934-0500 c168
WhenExported: 20231014014322-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1435
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Sat, 14 Oct 2023 06:39 UTC

Re: Run JS with a different TZ
By: Digital Man to nelgin on Fri Oct 13 2023 21:06:05

> Right. And environment variables are shared among on threads (e.g. nodes) of
> the sbbs instance, so even if you could set the TZ environment variable,
> you'd be changing for all threads. Likely not what you want.

Definitely not what I want.

> There's a whole new JS Date thing in the works for some future version of
> JavaScript, but that'll be aways away from being integrated with sbbs.
>
> I think the easiest thing to do would be to adjust the UTC value based on
> the UTC offset for central time (yeah, it'll change with DST) and then use
> Date.toUTCString() to convert it to a string.

I'll probably stick with using the moment-timezone library then. I use it in my weather script so I'm not unfamiliar with it, but I was trying to see if there was a more native way to handle timezone conversions.

Thanks,
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652AACA3.21.dove-syncjs@bbs.thefbo.us>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=102&group=DOVE-Net.Synchronet_Javascript#102

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: charles.blackburn@VERT/THEFBO (Charles Blackburn)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652AACA3.21.dove-syncjs@bbs.thefbo.us>
Date: Sat, 14 Oct 2023 10:58:43 -0400
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: The FBO BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <6529D976.1433.dove-syncjs@endofthelinebbs.com>
References: <6529D976.1433.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Linux master/f28c4bc94 Sep 17 2023 GCC 12.3.0
X-FTN-CHRS: CP437 2
WhenImported: 20231014120041-0700 c1e0
WhenExported: 20231014151316-0700 c1e0
ExportedFrom: VERT sync-js 3943
WhenImported: 20231014105843-0400 c12c
WhenExported: 20231014150039-0400 c12c
ExportedFrom: THEFBO dove-syncjs 21
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Charles Blackburn - Sat, 14 Oct 2023 14:58 UTC

Re: Run JS with a different TZ
By: nelgin to Digital Man on Fri Oct 13 2023 18:57:42

> Re: Run JS with a different TZ
> By: Digital Man to nelgin on Fri Oct 13 2023 13:33:06
>
> > Okay, so if it's in UTC, it's in central *or* eastern US. It's UTC.
>
> > Example:
> > jsexec '-r Date("2023-10-13T23:30:00Z")'
>
> jsexec '-r Date("2023-10-13T23:30:00Z")'
> Result (string): Fri Oct 13 2023 18:54:33 GMT-0500 (CDT)

if you know it's in UTC format then something like this should work (first result from google)

https://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript

##### code from the above url

function convertTZ(date, tzString) {
return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
}

// usage: Asia/Jakarta is GMT+7
convertTZ("2012/04/20 10:10:30 +0000", "Asia/Jakarta") // Tue Apr 20 2012 17:10:30 GMT+0700 (Western Indonesia Time)

// Resulting value is regular Date() object
const convertedDate = convertTZ("2012/04/20 10:10:30 +0000", "Asia/Jakarta")
convertedDate.getHours(); // 17

// Bonus: You can also put Date object to first arg
const date = new Date()
convertTZ(date, "Asia/Jakarta") // current date-time in jakarta.

charlie

---
■ Synchronet ■ My Brand-New BBS

Run JS with a different TZ

<652B57E3.1437.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=103&group=DOVE-Net.Synchronet_Javascript#103

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Charles Blackburn
Subject: Run JS with a different TZ
Message-ID: <652B57E3.1437.dove-syncjs@endofthelinebbs.com>
Date: Sat, 14 Oct 2023 22:09:23 -0500
X-Comment-To: Charles Blackburn
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652AACA3.21.dove-syncjs@bbs.thefbo.us>
References: <652AACA3.21.dove-syncjs@bbs.thefbo.us>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231014202252-0700 c1e0
WhenExported: 20231014211315-0700 c1e0
ExportedFrom: VERT sync-js 3944
WhenImported: 20231014220923-0500 c168
WhenExported: 20231014221331-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1437
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Sun, 15 Oct 2023 03:09 UTC

Re: Run JS with a different TZ
By: Charles Blackburn to nelgin on Sat Oct 14 2023 10:58:43

> function convertTZ(date, tzString) {
> return new Date((typeof date === "string" ? new Date(date) :
> date).toLocaleString("en-US", {timeZone: tzString}));
> }

You did actually try this and discovred it doesn't actually work, right?
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652C5FCE.23.dove-syncjs@bbs.thefbo.us>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=104&group=DOVE-Net.Synchronet_Javascript#104

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: charles.blackburn@VERT/THEFBO (Charles Blackburn)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652C5FCE.23.dove-syncjs@bbs.thefbo.us>
Date: Sun, 15 Oct 2023 17:55:26 -0400
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: The FBO BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652B57E3.1437.dove-syncjs@endofthelinebbs.com>
References: <652B57E3.1437.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Linux master/f28c4bc94 Sep 17 2023 GCC 12.3.0
X-FTN-CHRS: CP437 2
WhenImported: 20231015205415-0700 c1e0
WhenExported: 20231016031317-0700 c1e0
ExportedFrom: VERT sync-js 3945
WhenImported: 20231015175526-0400 c12c
WhenExported: 20231015210049-0400 c12c
ExportedFrom: THEFBO dove-syncjs 23
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Charles Blackburn - Sun, 15 Oct 2023 21:55 UTC

Re: Run JS with a different TZ
By: nelgin to Charles Blackburn on Sat Oct 14 2023 22:09:23

> Re: Run JS with a different TZ
> By: Charles Blackburn to nelgin on Sat Oct 14 2023 10:58:43
>
> > function convertTZ(date, tzString) {
> > return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
> > }
>
> You did actually try this and discovred it doesn't actually work, right?

can't say i did, i'm not a jS programmer, but was just throwing an idea out. but there should be a way to do it. In C/Python you can do it
in a similar way. if the string is in UTC you should be able to internally convert it to whatever TZ you want.

Charlie

---
■ Synchronet ■ My Brand-New BBS

Run JS with a different TZ

<652CA7F6.3422.sync_js@bbses.info>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=105&group=DOVE-Net.Synchronet_Javascript#105

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: mro@VERT/BBSESINF (MRO)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652CA7F6.3422.sync_js@bbses.info>
Date: Sun, 15 Oct 2023 22:03:18 -0500
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: bbses.info
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652B57E3.1437.dove-syncjs@endofthelinebbs.com>
References: <652B57E3.1437.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.19b-Win32 master/a2a9dc027 Jan 2 2022 MSC 1928
X-FTN-CHRS: CP437 2
WhenImported: 20231015205415-0700 c1e0
WhenExported: 20231016031317-0700 c1e0
ExportedFrom: VERT sync-js 3946
WhenImported: 20231015220318-0500 c168
WhenExported: 20231015223348-0500 c168
ExportedFrom: BBSESINF sync_js 3422
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: MRO - Mon, 16 Oct 2023 03:03 UTC

Re: Run JS with a different TZ
By: nelgin to Charles Blackburn on Sat Oct 14 2023 10:09 pm

> Re: Run JS with a different TZ
> By: Charles Blackburn to nelgin on Sat Oct 14 2023 10:58:43
>
> > function convertTZ(date, tzString) {
> > return new Date((typeof date === "string" ? new Date(date) :
> > date).toLocaleString("en-US", {timeZone: tzString}));
> > }
>
> You did actually try this and discovred it doesn't actually work, right?

this looks like a job for Chad Jipiti
---
■ Synchronet ■ ::: BBSES.info - free BBS services :::

Run JS with a different TZ

<652CE102.1439.dove-syncjs@endofthelinebbs.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=106&group=DOVE-Net.Synchronet_Javascript#106

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (nelgin)
To: Charles Blackburn
Subject: Run JS with a different TZ
Message-ID: <652CE102.1439.dove-syncjs@endofthelinebbs.com>
Date: Mon, 16 Oct 2023 02:06:42 -0500
X-Comment-To: Charles Blackburn
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652C5FCE.23.dove-syncjs@bbs.thefbo.us>
References: <652C5FCE.23.dove-syncjs@bbs.thefbo.us>
X-FTN-PID: Synchronet 3.20a-Linux master/1114452e3 Oct 9 2023 GCC 11.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20231016000719-0700 c1e0
WhenExported: 20231016031317-0700 c1e0
ExportedFrom: VERT sync-js 3948
WhenImported: 20231016020642-0500 c168
WhenExported: 20231016020723-0500 c168
ExportedFrom: EOTLBBS dove-syncjs 1439
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nelgin - Mon, 16 Oct 2023 07:06 UTC

Re: Run JS with a different TZ
By: Charles Blackburn to nelgin on Sun Oct 15 2023 17:55:26

> can't say i did, i'm not a jS programmer, but was just throwing an idea out.
> but there should be a way to do it. In C/Python you can do it
> in a similar way. if the string is in UTC you should be able to internally
> convert it to whatever TZ you want.

Unforuntately, there isn't. That's why there's moment-timezone and Luxon.

Unfortunately Luxon is too modern to work with the sbbs version of js. moment-timezone is no longer developed or supported but at least it works.
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com

Run JS with a different TZ

<652D6E32.27.dove-syncjs@bbs.thefbo.us>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=107&group=DOVE-Net.Synchronet_Javascript#107

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: charles.blackburn@VERT/THEFBO (Charles Blackburn)
To: nelgin
Subject: Run JS with a different TZ
Message-ID: <652D6E32.27.dove-syncjs@bbs.thefbo.us>
Date: Mon, 16 Oct 2023 13:09:06 -0400
X-Comment-To: nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: The FBO BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <652CE102.1439.dove-syncjs@endofthelinebbs.com>
References: <652CE102.1439.dove-syncjs@endofthelinebbs.com>
X-FTN-PID: Synchronet 3.20a-Linux master/f28c4bc94 Sep 17 2023 GCC 12.3.0
X-FTN-CHRS: CP437 2
WhenImported: 20231016120045-0700 c1e0
WhenExported: 20231016151314-0700 c1e0
ExportedFrom: VERT sync-js 3949
WhenImported: 20231016130906-0400 c12c
WhenExported: 20231016150046-0400 c12c
ExportedFrom: THEFBO dove-syncjs 27
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Charles Blackburn - Mon, 16 Oct 2023 17:09 UTC

Re: Run JS with a different TZ
By: nelgin to Charles Blackburn on Mon Oct 16 2023 02:06:42

> Re: Run JS with a different TZ
> By: Charles Blackburn to nelgin on Sun Oct 15 2023 17:55:26
> > can't say i did, i'm not a jS programmer, but was just throwing an idea
> > out. but there should be a way to do it. In C/Python you can do it
<CUT>
> Unforuntately, there isn't. That's why there's moment-timezone and Luxon.
> Unfortunately Luxon is too modern to work with the sbbs version of js.
> moment-timezone is no longer developed or supported but at least it works.

well that sucks... maybe sbbs (unless there's a specific reason for it) should use the system-wide version maybe? I know it may be more work for the devs, but just my tuppence :D

as for the latter, maybe you should fork it and take it over lol

Charlie

---
■ Synchronet ■ My Brand-New BBS


dovenet / Synchronet Javascript / Run JS with a different TZ

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor