Skip to content

POSIX and summer savings time

4 messages · Derek Eder, Brian Ripley

#
I have a time stamp in UTC (GMT) time:

 >  format(ISOdatetime(1970,1,1,0,0,0)+1165398135729/1000,"%Y-%m-%d 
%H:%M:%OS3")

"2006-12-06 09:42:18.823"  (note millisecond accuracy, but not relevant 
to question here)

Now, this time stamp actually "happened" at local (Swedish) time one 
hour later (10:42).

Regarding summer/winter adjustments in time ("spring forward, fall 
back"):   Is there a way of automatically recovering the local time 
adjustments for a given date?  E.g., a date/time in springtime = GMT +2 
, else GMT +1

Thanks,

Derek Eder
#
On Wed, 6 Dec 2006, Derek Eder wrote:

            
But it is the wrong answer, and not what my system gives.
So you need to tell R that it was in UTC, which is what the 'tz' argument 
is for:
[1] "2006-12-06 09:42:15 UTC"
[1] "2006-12-06 10:42:15.729"
Is the above not enough?  You can unpick it if you want to get the shift.
#
When I tried Professor Ripley's example (below), the "tz" argument 
failed to adjust clock time from UTC.

 > (z <- ISOdatetime(1970,1,1,0,0,0, tz="UTC")+1165398135729/1000)
[1] "2006-12-06 09:42:15 UTC"


 > format(z, "%Y-%m-%d %H:%M:%OS3",tz = "CET")
[1] "2006-12-06 09:42:15.729"
# expected CET (Central European Time) clock time is UTC + 1 hour time 
zone adjustment


Am I running into platform dependencies?

(my platform)
platform       i386-pc-mingw32            
arch           i386                       
os             mingw32                    
system         i386, mingw32              
status                                    
major          2                          
minor          4.0                        
year           2006                       
month          10                         
day            03                         
svn rev        39566                      
language       R                          
version.string R version 2.4.0 (2006-10-03)


Thank you most sincerely,

Derek Eder
Prof Brian Ripley wrote:

  
    
#
CET is not a valid timezone *on Windows*: please do RTFM.
E.g. ?Sys.timezone says

      'Sys.timezone' returns an OS-specific character string, possibly
      an empty string.  It may be possible to set the timezone via the
      environment variable '"TZ"': see 'as.POSIXlt'. Windows is
      notorious for naming its timezones differently from the official
      names.

and ?as.POSIXlt points you at

      a specification of the form 'GST-1GDT',

which seems to be the same as CET, and that works on my Windows laptop.
It is also possible that tz="" works for you: it seems to for me when I 
set my machine to CET.
On Thu, 7 Dec 2006, Derek Eder wrote: