0

I am using python code in Synapse Portal.

I call time.time to get the current time from the PC in seconds, adjust the value to a different Epoch, convert it to a string and transmit it via radio to a set of gardening robots, a weather station etc.

Everything was working fine during daylight savings time but after DST ended time.time returns a value that is off by an hour. The PC clock shows the correct time. Why doesn't python get the time from the same place the PC gets the time for its clock applet?

Of course, I can overcome the problem by subtracting 3600 seconds during the conversion to the other Epoch but this is not elegant. Any info about this will be very much appreciated. (I'm new to python with an assembler & C background, Synapse uses a very small subset of python in its radio/processor modules so easy to accomplish simple things but the Portal app which runs on the PC uses the full python).

The main question then is, how to get python to dependably report the correct time?

Stuart
  • 6,630
  • 2
  • 24
  • 40
  • Possible duplicate of [python time.time() and "Daylight Saving Time"](http://stackoverflow.com/questions/32469318/python-time-time-and-daylight-saving-time) – iCart Nov 21 '16 at 12:43
  • For best results, it's encouraged to show us some actual code that reproduces your problem. Otherwise, we're just talking in the abstract. In this case, you say that `time.time` is returning a value that's an hour off, but you didn't give us any examples. Perhaps the error is actually in your code that uses the timestamp, rather than with the value itself. Please edit your question to be more specific. Also, read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Thanks. – Matt Johnson-Pint Nov 21 '16 at 17:26

0 Answers0