TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2019-11-03 13:37:00
subject: Re: Python - set current

On Sun, 3 Nov 2019 08:20:59 +0100, "R.Wieser" 
declaimed the following:

>
>A very basic property of the OS (which you can /read/ from in a slew of
>ways), but no way to set it.
>

 Well, applications often need the current time for reporting purposes
-- but said time should rarely need to be set, and all OSs that I know of
provide command line utilities for setting it.

>I can understand, in a multi-user machine, why not just anybody should be
>able to muck around with it, but disallowing even root users to easily
>change it ...
>
 Thing is -- it is the OS that is multi-user, even if you consider it a
single-user machine. There may things running that rely upon the clock
never going backwards (note that going to/from daylight savings time is NOT
moving the clock itself -- the clock runs UTC and computes the shift based
upon environment settings). Not to mention that the clock is actually
counting seconds since some date in 1970.

>Than again, I'm not just a linux user.  I've bought a Raspberry for a reason
>(so many GPIO pins, my preciousss). :-)
>
 If it's GPIO pins you crave -- take a look at a Beaglebone Black (which
also has analog I/O). Granted, that single core 1GHz processor looks wimpy
these days but... it does have a pair of PRU processors (basically 200MHz
micro-controllers) for realtime work. Runs Debian so no real difference
from R-Pi "Raspbian".

>
>I don't know either.   But its certainly something to pursue.   Although ...
>having to convert a set of simple date & time values into a datetime float
>might be its own challenge ...
>

 Well, as hinted above, that float is just seconds from 1970.

>>> time.mktime((2019, 11, 3, 13, 11, 30, 0, 0, 0))
1572804690.0
>>> time.ctime()
'Sun Nov  3 13:11:01 2019'
>>> time.time()
1572804665.9523017
>>>

(Confusing in that inputs are Y M D H M S, but also weekday and julian day
number -- I set both to 0; the last 0 is DST-no) What may be a concern is
that expects the time as /local/ time, using the environment

 Or, staying just in datetime to get the float value (still using time.*
for comparison)

>>> datetime.datetime(2019, 11, 3, 13, 38, 45, 0,
datetime.timezone(datetime.timedelta(hours=-5), "EST")).timestamp()
1572806325.0
>>> time.time()
1572806049.7643929
>>> time.ctime()
'Sun Nov  3 13:34:16 2019'
>>>



--
 Wulfraed                 Dennis Lee Bieber         AF6VN
 wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.