Short answer: these are OS-specific bugs documented in the R help - see the bottom.
On Wed, 16 Aug 2006, Erich Neuwirth wrote: > I am running R 2.3.1 on Windows XP. > My machine is set (via the Windows Control Panel) to Central European > time (Amsterdam, Berlin, Rome, Stockholm, Vienna) and automatically has > DST set, so I am 2 hours ahead of GMT. > No TZ variable is set. > > > Sys.timezone() > [1] "W. Europe Standard Time" > > Sys.Date() > [1] "2006-08-15" > > as.POSIXlt(Sys.Date()) > [1] "2006-08-15" > > as.POSIXct(Sys.Date()) > [1] "2006-08-15 02:00:00 W. Europe Standard Time" > > as.POSIXct(as.POSIXlt(Sys.Date())) > [1] "2006-08-15 01:00:00 W. Europe Standard Time" > > Converting to POSIXct and converting to POSIXlt and then to POSIXct > produces different results, which is rather strange. > > When I do > > Sys.time() > [1] "2006-08-16 00:12:40 W. Europe Standard Time" > > I get my clock time with numerically correct time for my location, but > with an incorrect timezone stamp. > > If I set TZ=CET, something else happens. > It is just past midnight, my Windows system clock shows > 12:33 AM, and the date is Aug 16 (here in Austria) > With TZ=CET, > > > Sys.Date() > [1] "2006-08-15" > > Sys.time() > [1] "2006-08-15 22:33:30 CET" > > So I get current GMT time (my time - 2 hours) and date, > but with a CET time stamp. > > When TZ does not have a value, > > Sys.Date() > [1] "2006-08-16" > > Sys.time() > [1] "2006-08-16 00:32:37 W. Europe Standard Time" > > This is numerically correct time and date, but with an incorrect > timezone stamp. > > So I never get completely correct information, > even when Windows timezone information is correct and TZ has > the correct value. > Is this something which should be corrected? Yes, by Microsoft. Their labelling of timezones is a known bug. E.g. I get > as.POSIXct(Sys.Date()) [1] "2006-08-16 01:00:00 GMT Daylight Time" and there is no such timezone. However, if I set my Windows XP SP2 system to your timezone I do get > as.POSIXct(Sys.Date()) [1] "2006-08-16 02:00:00 W. Europe Daylight Time" so something is wrong specific to your machine. 'CET' is not a valid timezone on Windows (where did you get that it was?), and the help (for as.POSIXlt) does say that what happens then is OS-specific. Again, it does explain that Windows has bugs in its setting of timezones so there appears to be no valid way to set programatically non-US timezones with DST on that benighted OS. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel