>
> The only thing I'm not sure about is how various time zones change in their
> relationship to GMT (eg Summer Time etc.) For example if Country A is
> normally on GMT -8 but they're currently on Summer Time so 7AM in that time
> zone is CurrentHourGMT-8+1, how do we account for that?
>
> One idea I have is to get a list of timezones using sudo - eg
> sudo system setup -listtimezones
> but I haven't been able to get that to work using LEP - eg
>
to get the local Time(zone) on a Mac with LEP you could use one of these
commands:
date +%z
date +"%Z %z"
ls -l /etc/localtime
curl https://ipapi.co/timezone
Cheers,
Bernd
Am Mi., 26. Sep. 2018 um 15:17 Uhr schrieb Pat Bensky via 4D_Tech <
4d_tech@lists.4d.com>:
> After trying various complicated methods of calculating the different time
> zones, the final method was actually quite simple.
> I needed to set up an email-sending routine to send emails out at 7AM for
> each time zone. This is what I have. This is currently being tested :)
> Please feel free to point out any obvious flaws!
>
> // get the current GMT time
>
> *XML DECODE*(*Delete string*(*String*(*Current date*;ISO date GMT;*Current
> time*);20;1);$tTime)
>
> $CurrentHourGMT:=*Num*(*Substring*(*String*($tTime);1;2))
>
> // get the difference between current GMT and 7AM
>
> *If* ($CurrentHourGMT>=7)
>
> $TimeZoneDiff:=($CurrentHourGMT-7)*-1 // gives us a starting point for
> where it is currently 7AM
>
> *Else*
>
> $TimeZoneDiff:=7-$CurrentHourGMT
>
> *End if*
>
> $Current7AM:=$TimeZoneDiff
>
> *For* ($i;1;24)
>
> * QUERY*([Emails];[Emails]gmt=$Current7AM)
>
> // send the emails
>
> *Case of*
>
> *:* ($Current7AM=0)
>
> $Current7AM:=-1
>
> *:* ($Current7AM=-11)
>
> $Current7AM:=12
>
> *Else*
>
> $Current7AM:=$Current7AM-1
>
> *End case*
>
> $lastHour:=$CurrentHourGMT
>
> *While* ($CurrentHourGMT<=$lastHour)
>
> *DELAY PROCESS*(*Current process*;$DelayTime)
>
> *If* ($testing)
>
> $CurrentHourGMT:=$CurrentHourGMT+1
>
> *Else*
>
> *XML DECODE*(*Delete string*(*String*(*Current date*;ISO date GMT;*Current
> time*);20;1);$tTime)
>
> $CurrentHourGMT:=*Num*(*Substring*(*String*($tTime);1;2))
>
> *End if*
>
> *End while*
>
> End For // 24 iterations
>
> The only thing I'm not sure about is how various time zones change in their
> relationship to GMT (eg Summer Time etc.) For example if Country A is
> normally on GMT -8 but they're currently on Summer Time so 7AM in that time
> zone is CurrentHourGMT-8+1, how do we account for that?
>
>
> One idea I have is to get a list of timezones using sudo - eg
>
> sudo system setup -listtimezones
>
> but I haven't been able to get that to work using LEP - eg
>
> * C_TEXT*($result)
>
> $cmd:="sudo systemsetup -listtimezones"
>
> *LAUNCH EXTERNAL PROCESS*($cmd;$result)
>
> $result is always empty - I guess I'm doing something wrong!
> Then maybe go through each timezone, temporarily switch the machines's zone
> sudo system setup - settimezone timezone
>
> Get the current time in that zone and calculate its difference from GMT ...
> Save all those results into a lookup array.
>
> Any ideas about that?
>
> Pat
>
>
> On Tue, 25 Sep 2018 at 14:07, Jody Bevan via 4D_Tech <4d_tech@lists.4d.com
> >
> wrote:
>
> > Pat:
> >
> > Thanks. I will try it out. I will see if then I can figure out getting it
> > for the different time zones without having it hard coded in.
> >
> > Jody
> >
> >
> > > On Sep 24, 2018, at 4:28 PM, Pat Bensky via 4D_Tech <
> > 4d_tech@lists.4d.com> wrote:
> > >
> > > Using v16:
> > > I've figured out how to get the current GMT time using cURL. (Code at
> the
> > > bottom if anybody is interested).
> > > Now I need to get the current time in a different time zone - eg in
> > France.
> > > Any ideas how to do that?
> > >
> > >
> > >
> > > ==
> > >
> > > // GetTimeGMT
> > >
> > > // Gest the current time in GMT from Google
> > >
> > > // 21/09/18 pb
> > >
> > > *C_LONGINT*(*$0*)
> > >
> > > $input:="curl -I https://www.google.com/"; // this gets GMT from
> Google
> > >
> > > $empty:=""
> > >
> > > *LAUNCH EXTERNAL PROCESS*($input;$empty;$output;$error)
> > >
> > > *$0*:=0
> > >
> > > *If* ($output#"")
> > >
> > > $pos:=*Position*("GMT";$output)
> > >
> > > *If* ($pos>0)
> > >
> > > $time:=*Substring*($output;$pos-9;8)
> > >
> > > $pos:=*Position*(":";$time)
> > >
> > > *If* ($pos>0)
> > >
> > > *$0*:=*Num*(*Substring*($time;1;$pos-1))
> > >
> > > *End if*
> > >
> > > *End if*
> > >
> > > *End if*
> > >
> > > --
> > > *
> > > CatBase - Top Dog in Data Publishing
> > > tel: +44 (0) 207 118 7889
> > > w: http://www.catbase.com
> > > skype: pat.bensky
> > > *
> > > **
> > > 4D Internet Users Group (4D iNUG)
> > > Archive: http://lists.4d.com/archives.html
> > > Options: https://lists.4d.com/mailman/options/4d_tech
>