This bumpy workaround I'm going to share (in case somebody might be interested) isn't meant to answer the original question of this thread but helped me to fix the ported system_date_time functions for my smartphone.

These I had defined for the use within a Windows PC environment, mimicking the ISO date-time string (simply as a wrapper for 6!:0):

tz=: {{      NB. timezone info
 if. IFUNIX do.
  2!:5'TZ'
 elseif. IFWIN do.
  shell 'tzutil /g' [ require 'task'     NB. as suggested by Raul
 end.
}}

sdtfz=: {{ (sdtf''),' ',(tz'') }}     NB. ~ISO, w/ TimeZone information added

with example output

   sdtfz''     NB. ~ISO, system date-time, formatted w/ TZ
2022-06-13 15:19:51.4 UTC

This is the version I now use on my SONY Xperia Z3 Compact D5803
running Android v4.4.4 (KitKat), which lets me
choose a timezone (equivalent to UTC) different from the provider's
but date-time still updated over the network:

tz=: {{
 NB. get Android date (e.g.: Mon Jun 20 10:50:01 AZOST 2022)
 ad=. shell 'date'
 NB. define Blank
 BL=.  32 { a.
 NB. get list of blanks in the date string
 lob=. ad = BL
 NB. get indices of those 5 blanks
 iob=. I. lob
 NB. calc index of tz start
 izs=. >: 3 { iob
 NB. calc index of tz end
 ize=. <: 4 { iob
 NB. calc tz string length
 tzl=. >: ize - izs
 NB. extract TZ string
 TZ=. (izs + i. tzl) { ad
}}

Now these are working again:

   tz''
AZOST

   sdtfz''
2022-06-20 14:54:09.8 AZOST

-M


At 2022-06-13 18:49, you wrote:

On my phone (an iphone 7):

Yes, TZ is not defined for you (nor for me on this phone).

Plausibly a consequence of over zealous security measures, though more
likely a consequence of the "long running process" model for phones  where
many phone users (particularly influential users) frequently change time
zones without rebooting their phone.

Thanks,

--
Raul

On Mon, Jun 13, 2022 at 2:40 PM Martin Kreuzer <i...@airkreuzer.com> wrote:

> On my phone (Android v4.4.4) I get

>     2!:5 'TZ'
> 0

> which is to say that this environment variable doesn't exist?

>     JVERSION
> Engine: j03/j32/android
> Release-a: commercial/2022-01-08T13:47:02
> Library: 9.03.08
> J Android: 1.4.17/4.4.4/19
> ...

> -M

> At 2022-06-12 04:01, you wrote:

> >If you are running under a unix-like operating system, 2!:5'TZ' should
> work.
> >
> >If you are running under windows, on an older version of J, I think
> >2!:0'tzutil /g' would work.
> >
> >In more recent versions of J, something has gone wrong with 2!:0 so
> >instead you would use
> >
> >require'task'
> >shell'tzutil /g'
> >
> >Note that all of these approaches provide a textual result.
> >
> >I hope this helps,
> >
> >--
> >Raul
> >
> >For information about J forums see http://www.jsoftware.com/forums.htm

> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to