File: as.Date.Rout.save

package info (click to toggle)
r-zoo 1.8-14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,760 kB
  • sloc: ansic: 373; makefile: 2
file content (139 lines) | stat: -rw-r--r-- 3,491 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

R version 4.0.4 (2021-02-15) -- "Lost Library Book"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ## set Z's timezone for reproducibility
> Sys.setenv(TZ = "Europe/Vienna")
> 
> ## base results
> as.Date(10957, origin = "1970-01-01")
[1] "2000-01-01"
> as.Date("2000-01-01")
[1] "2000-01-01"
> as.Date(as.POSIXct("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(as.POSIXlt("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(NA)
[1] NA
> 
> ## for chron objects
> library("chron")
> as.Date(dates("01/01/2000"))
[1] "2000-01-01"
> as.Date(chron("01/01/2000", "00:00:00"))
[1] "2000-01-01"
> 
> ## for tis objects
> library("tis")
> as.Date(ti(20000101, "daily"))
[1] "2000-01-01"
> as.Date(jul(20000101))
[1] "2000-01-01"
> 
> ## for timeDate objects
> library("timeDate")

Attaching package: 'timeDate'

The following objects are masked from 'package:tis':

    dayOfWeek, dayOfYear, isHoliday

> as.Date(timeDate("2000-01-01"))
[1] "2000-01-01"
> 
> ## with zoo attached (masking as.Date/as.Date.numeric)
> library("zoo")

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

> as.Date(10957)
[1] "2000-01-01"
> as.Date("2000-01-01")
[1] "2000-01-01"
> as.Date(as.POSIXct("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(as.POSIXlt("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(NA)
[1] NA
> as.Date(yearmon(2000))
[1] "2000-01-01"
> as.Date(yearqtr(2000))
[1] "2000-01-01"
> as.Date(dates("01/01/2000"))
[1] "2000-01-01"
> as.Date(chron("01/01/2000", "00:00:00"))
[1] "2000-01-01"
> as.Date.ti <- tis:::as.Date.ti                  ## filed request for export
> as.Date(ti(20000101, "daily"))
[1] "2000-01-01"
> as.Date.jul <- tis:::as.Date.jul                ## filed request for export
> as.Date(jul(20000101))
[1] "2000-01-01"
> as.Date.timeDate <- timeDate:::as.Date.timeDate ## filed request for export
> as.Date(timeDate("2000-01-01"))
[1] "2000-01-01"
> 
> ## with mondate attached (masking again as.Date)
> library("mondate")

Attaching package: 'mondate'

The following objects are masked from 'package:tis':

    day, month, quarter, year, ymd

The following object is masked from 'package:base':

    as.difftime

> as.Date(10957)
[1] "2000-01-01"
> as.Date("2000-01-01")
[1] "2000-01-01"
> as.Date(as.POSIXct("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(as.POSIXlt("2000-01-01 00:00:00 GMT", tz = "GMT"))
[1] "2000-01-01"
> as.Date(NA)
[1] NA
> as.Date(yearmon(2000))
[1] "2000-01-01"
> as.Date(yearqtr(2000))
[1] "2000-01-01"
> as.Date(dates("01/01/2000"))
[1] "2000-01-01"
> as.Date(chron("01/01/2000", "00:00:00"))
[1] "2000-01-01"
> as.Date(ti(20000101, "daily"))
[1] "2000-01-01"
> as.Date(jul(20000101))
[1] "2000-01-01"
> as.Date(timeDate("2000-01-01"))
[1] "2000-01-01"
> as.Date(mondate(1/31))
[1] "2000-01-01"
> 
> 
> proc.time()
   user  system elapsed 
  0.491   0.028   0.512