Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:07 23 Jan 2026 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 : Testing for a particular time period

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1016
Posted: 11:48pm 22 Jan 2026
Copy link to clipboard 
Print this post

I am using many displays that are active 24/7 and would like to lower the backlight during evening hours. I have used a test to look for 07:00:00 and 19:00:00 time stamps which works OK but occasionally that time stamp is missed due to other operations of the program. I would like to test if the time is past 07:00:00 and 19:00:00 to reduce or increase the backlight. I vagally remember discussions of an EPOC command but I can't find any mention in the handbooks. Would this be the direction I should head?

Regards
OA47
 
Andy-g0poy
Regular Member

Joined: 07/03/2023
Location: United Kingdom
Posts: 83
Posted: 12:02am 23 Jan 2026
Copy link to clipboard 
Print this post

EPOCH(DATETIME$)

and NOW
Print EPOCH(NOW)

Page 187



DATETIME$(n) returns the date time string fromthe epoch number n

page 185


Using the pdf manual
MMBasic BASIC Interpreter
Ver 6.01.00

Andy
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6437
Posted: 12:58am 23 Jan 2026
Copy link to clipboard 
Print this post

Time$ is a string and you can compare strings
'
IF TIME$ >= "07:00:00" AND TIME$ < "19:00:00" THEN
 backlight = 100
ELSE
 backlight = 20
ENDIF


VK7JH
MMedit
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2951
Posted: 02:25am 23 Jan 2026
Copy link to clipboard 
Print this post

That is clever, easier than Epoch.
> TIME$ = "06:55" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
0
> TIME$ = "07:05" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
1
> TIME$ = "18:55" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
1
> TIME$ = "19:05" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
0
>

> night = 19*60*60
> day = 7*60*60
> aDay =  24*60*60
> if epoch(now) mod aDay > night then backlight 10
> if epoch(now) mod aDay > day then backlight 100

Edited 2026-01-23 12:29 by phil99
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 178
Posted: 02:45am 23 Jan 2026
Copy link to clipboard 
Print this post

As a general guideline for programming limit or range logic I'd suggest checking for > or < as appropriate unless circumstances preclude doing so. ie not just = to.
A lot more people can program when the real world behaves as they expect their virtual world to behave. A good programmer should strive to program for when the real world is real and things don't behave in a virtual manner. ie program for the worst case, not the best case especially if your version of logic says it can't happen, it will.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1016
Posted: 03:27am 23 Jan 2026
Copy link to clipboard 
Print this post

Thankyou all, I will use the string comparison.

OA47
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026