[R] problem with unlist POSIX date at midnight

From: Hanneke Schuurmans <H.Schuurmans_at_geo.uu.nl>
Date: Wed 17 Jan 2007 - 09:42:32 GMT


Dear R-users,

I use unlist of POSIX dates to extract the year, hour etc. With that I can search for files in my database which are in the form 'yyyymmddhh_synops.txt'
However, I get stucked during midnight where unlist just gives NA's. The script is given below, the problem accurs at acc.period[16] (midnight). However when I write out the character, unlist works well.
But as.character(acc.period[16]) is not the solution....

begin=paste(dates[i]-1,"09:00:00")
end=paste(dates[i],"08:00:00")
acc.period=seq(as.POSIXct(begin),as.POSIXct(end),"hour")

unlist(strptime(acc.period[16],format="%Y-%m-%d %H:%M:%S"))
# sec min hour mday mon year wday yday isdst
# NA NA NA NA NA NA NA NA -1
unlist(strptime(acc.period[17],format="%Y-%m-%d %H:%M:%S"))
# sec min hour mday mon year wday yday isdst
 # 0 0 1 1 2 106 3 59 0  

 a="2006-03-01 00:00:00"
 unlist(strptime(a,format="%Y-%m-%d %H:%M:%S"))
# sec min hour mday mon year wday yday isdst
# 0 0 0 1 2 106 3 59 0

Could someone help?

Thanks in advance!

Hanneke

-- 
---------------------------------------------
ir J.M. (Hanneke) Schuurmans
PhD student Hydrology
Department of Physical Geography
Faculty of Geosciences - Universiteit Utrecht
P.O. Box 80115  3508 TC  Utrecht
T +31 (0)30 2532988  F +31 (0)30 2531145
W www.geo.uu.nl/staff/schuurmans

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jan 17 20:47:08 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 17 Jan 2007 - 10:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.