The R Project SVN R

Rev

Rev 59039 | Rev 64657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59039 Rev 61150
Line 145... Line 145...
145
## read in date/time info in format 'm/d/y'
145
## read in date/time info in format 'm/d/y'
146
dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92")
146
dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92")
147
as.Date(dates, "\%m/\%d/\%y")
147
as.Date(dates, "\%m/\%d/\%y")
148
 
148
 
149
## date given as number of days since 1900-01-01 (a date in 1989)
149
## date given as number of days since 1900-01-01 (a date in 1989)
150
as.Date(32768, origin="1900-01-01")
150
as.Date(32768, origin = "1900-01-01")
151
## Excel is said to use 1900-01-01 as day 1 (Windows default) or
151
## Excel is said to use 1900-01-01 as day 1 (Windows default) or
152
## 1904-01-01 as day 0 (Mac default), but this is complicated by Excel
152
## 1904-01-01 as day 0 (Mac default), but this is complicated by Excel
153
## treating 1900 as a leap year.
153
## treating 1900 as a leap year.
154
## So for dates (post-1901) from Windows Excel
154
## So for dates (post-1901) from Windows Excel
155
as.Date(35981, origin="1899-12-30") # 1998-07-05
155
as.Date(35981, origin = "1899-12-30") # 1998-07-05
156
## and Mac Excel
156
## and Mac Excel
157
as.Date(34519, origin="1904-01-01") # 1998-07-05
157
as.Date(34519, origin = "1904-01-01") # 1998-07-05
158
## (these values come from http://support.microsoft.com/kb/214330)
158
## (these values come from http://support.microsoft.com/kb/214330)
159
 
159
 
160
## Experiment shows that Matlab's origin is 719529 days before ours,
160
## Experiment shows that Matlab's origin is 719529 days before ours,
161
## so Matlab day 734373 can be imported as
161
## so Matlab day 734373 can be imported as
162
as.Date(734373, origin = "1970-01-01") - 719529
162
as.Date(734373, origin = "1970-01-01") - 719529
Line 164... Line 164...
164
 
164
 
165
## Timezone effect
165
## Timezone effect
166
z <- ISOdate(2010, 04, 13, c(0,12)) # midnight and midday UTC
166
z <- ISOdate(2010, 04, 13, c(0,12)) # midnight and midday UTC
167
as.Date(z) # in UTC
167
as.Date(z) # in UTC
168
\donttest{## these timezone names are common
168
\donttest{## these timezone names are common
169
as.Date(z, tz ="NZ")
169
as.Date(z, tz = "NZ")
170
as.Date(z, tz ="HST") # Hawaii}
170
as.Date(z, tz = "HST") # Hawaii}
171
}
171
}
172
\keyword{utilities}
172
\keyword{utilities}
173
\keyword{chron}
173
\keyword{chron}