Re: [PATCHv2 1/4] util: new function virTimeLocalOffsetFromUTC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 23, 2014 at 02:43:08PM +0300, Laine Stump wrote:
> On 05/22/2014 09:49 PM, Marcelo Tosatti wrote:
> > On Thu, May 22, 2014 at 02:07:27PM +0300, Laine Stump wrote:
> >> Since there isn't a single libc API to get this value, this patch
> >> supplies one which gets the value by grabbing current UTC, then
> >> converting that into a struct tm with localtime_r(), then back to a
> >> time_t using mktime; it again does the same operation, but using
> >> gmtime_r() instead (for UTC). It then subtracts utc time from the
> >> localtime, and finally adjusts if dst is set in the localtime timeinfo
> >> (because for some reason mktime doesn't take that into account).
> >>
> >> This function should be POSIX-compliant, and is threadsafe, but not
> >> async signal safe. If it was ever necessary to know this value in a
> >> child process, we could cache it with a one-time init function when
> >> libvirtd starts, then just supply the cached value, but that
> >> complexity isn't needed for current usage.
> >> ---
> >>
> >> Change from V1: add test cases with TZ set to different values (if
> >> someone knows how to force DST on/off, I would gladly add some test
> >> cases for this as well).
> >
> > man tzset:
> >
> >        The second format is used when there is daylight saving time:
> >
> >               std offset dst [offset],start[/time],end[/time]
> 
> Aha! And combining that with the "VIR" timezone idea that we're already
> using, I've found that the following string *does* set DST:
> 
> TZ="VIR02:30VID,0,365"
> 
> while the following *doesn't* (at least not today :-):
> 
> TZ="VIR02:30VID,300,365"
> 
> So I can add the former as a test case.
> 
> Thanks!

Btw TZ also contains != 1hour daylight offset information (see that
section of man tzset).

I'll send a QEMU patch to add a command to query the RTC offset. 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]