Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29061
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: datetime |
| Date | 2012-09-13 14:07 -0400 |
| References | <loom.20120913T170328-631@post.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.626.1347559693.27098.python-list@python.org> (permalink) |
On 9/13/2012 11:19 AM, Max wrote: > How do I set the time in Python? If you look up 'time' in the index of the current manual, it directs you to the time module. "time.clock_settime(clk_id, time) Set the time of the specified clock clk_id. Availability: Unix. New in version 3.3." You did not specify *which* time to set, but ... "time.CLOCK_REALTIME System-wide real-time clock. Setting this clock requires appropriate privileges. Availability: Unix. New in version 3.3." Chris already suggested an approach for changing your process's idea of time. However, setting time.timezone seems to have no effect > Also, is there any *direct* way to shift it? If you mean time.clock_shift(clk_id, shift_seconds), no. time.clock_settime(clk_id, time.clock_gettime(clk_id) + delta_seconds) > Note that any "indirect" methods may need complicated ways to keep > track of the milliseconds lost while running them. Whay would a millisecond matter? System clocks are never synchronized to official UTC time that closely without special hardware to receive time broadcasts. > It even took around one > second in some virtual machine guest systems. So I'm hoping Python happens to > have the magic needed to do the job for me. The above should be well under a second. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: datetime Terry Reedy <tjreedy@udel.edu> - 2012-09-13 14:07 -0400
csiph-web