Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 17:25 19 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: EPOCH-alpypse NOW

Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3830
Posted: 10:53am 22 Oct 2021
Copy link to clipboard 
Print this post

Hi Peter,

I'm not asking for a change, just getting this straight in my own head so I can address the issue in MMB4L.

Am I correct in understanding that the CMM2 has no knowledge of time-zones and does everything assuming it is GMT ?

Specifically if I do:
Date$="22-10-2021"
Time$="11:50:00"
? Epoch(Now)


Then it's going to reply 1634899800

Which is the answer for GMT even though "Now" for me is actually BST - not that you can tell from the weather.

... it can't be any other way can it ... feels somewhat silly to ask you to confirm what I believe is the obvious.

On the CMM2:
Print Choice(DateTime$(Now) = DateTime$(Epoch(Now)), "true", "false")

always prints "true" ...

... it's not clear if that should be the case for MMB4L where my initial thought is that DateTime$(Now) should return the actual date and time now in the current time-zone ... hmm, any thoughts ?

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5705
Posted: 11:30am 22 Oct 2021
Copy link to clipboard 
Print this post

Could you keep it compatible with the other platforms but add an option to synchronise the MMBasic clock with the system clock?

OPTION USE SYSTIME ON

for example.

That way "time$=" and "a$=time$" would work as expected.

Or add an option:

OPTION TIMEZONE +2

to set time$ to system time +/- a figure.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3830
Posted: 11:41am 22 Oct 2021
Copy link to clipboard 
Print this post

  Mixtel90 said  Could you keep it compatible with the other platforms but add an option to synchronise the MMBasic clock with the system clock?


Hi Mick,

It's not my intention to have an independent MMBasic clock (it does have its own TIMER though), I feel that way lies madness. As a result MMB4L does not have the TIME$ and DATE$ (set) commands, only the (get) functions.

I think the problem lies with deciding what the API of EPOCH and DATETIME$ is. Should their input parameter be in GMT or should it be in the local timezone? The CMM2 implementation appears to assume they are in GMT but I think it also assumes that the CMM2 is GMT (set incorrectly by people not under GMT ) throughout.

Presumably the values returned from DATE$ & TIME$ should always be local timezone ? but does that imply the same for DATETIME$ ? or do we accept that sometimes DATE$ + " " + TIME$ will not be equal to DATETIME$(NOW) ?

Best wishes,

Tom
Edited 2021-10-22 21:48 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 11:56am 22 Oct 2021
Copy link to clipboard 
Print this post

The only way to simplify this I can think of (without building a complete timezone/summertime mechanism into MMBasic) is to remove the epoch(NOW) and datetime$(NOW) capabilities. Epoch is by definition referenced to UTC and datetime$ was designed to convert an epoch number to a text string. I added the "now" capabilites as a convenience but if you don't like the implications then remove them
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3830
Posted: 12:04pm 22 Oct 2021
Copy link to clipboard 
Print this post

  matherp said  The only way to simplify this I can think of (without building a complete timezone/summertime mechanism into MMBasic) is to remove the epoch(NOW) and datetime$(NOW) capabilities. Epoch is by definition referenced to UTC and datetime$ was designed to convert an epoch number to a text string. I added the "now" capabilites as a convenience but if you don't like the implications then remove them


Thanks Peter, I was considering adding an optional TZ parameter to both functions in a later alpha, but that still left the question of what the default behaviour should be.

Am I otherwise correct in my assessment that the CMM2 assumes it's GMT everywhere ?

Best wishes,

Tom
Edited 2021-10-22 22:08 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5705
Posted: 12:17pm 22 Oct 2021
Copy link to clipboard 
Print this post

As it doesn't have an internet connection or a DST setting it's almost certainly local time only, whatever the user sets it to. Doesn't have to be GMT, even if you install a RTC (which will depend on how you set it - DST would be done in software).
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 12:19pm 22 Oct 2021
Copy link to clipboard 
Print this post

  Quote  I am otherwise correct in my assessment that the CMM2 assumes it's GMT everywhere aren't I though ?


It doesn't assume anything. It is up to the programmer to make sense of this. The major use of epoch is likely to be scheduling events in which case it is agnostic to actual timezone


' want to do something at 21:00 local time every day
' assumes time and date are set to local
' can't care when the program is run
t%=epoch(now)
e%=epoch(date$+" 21:00:00")
settick e%-t%,myint

sub mytick
settick myint,86400
'do something every day at 21:00
end sub


it can also be used to convert to a different timezone


' I know my clock is set to UTC+6
' what is the time in London (assuming not BST)
' remember it could be yesterday so not easy to do in Basic
t%=epoch(now)-3600*6
? datatime%(t%)
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3830
Posted: 01:56pm 22 Oct 2021
Copy link to clipboard 
Print this post

Thanks Peter, I understand now even if I'm not entirely sure what I'm going to do about it.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024