Skip to content

Commit 19d5bd7

Browse files
authored
Merge pull request #40184 from rikhuijzer/patch-1
Show broadcasting with Date constructor
2 parents 04e2028 + cad20ea commit 19d5bd7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

stdlib/Dates/docs/src/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ julia> dt2 = Date("2015-01-02",df)
125125
2015-01-02
126126
```
127127

128+
Alternatively, use broadcasting:
129+
130+
```jldoctest
131+
julia> years = ["2015", "2016"];
132+
133+
julia> Date.(years, DateFormat("yyyy"))
134+
2-element Vector{Date}:
135+
2015-01-01
136+
2016-01-01
137+
```
138+
128139
You can also use the `dateformat""` string macro. This macro creates the `DateFormat` object once when the macro is expanded and uses the same `DateFormat` object even if a code snippet is run multiple times.
129140

130141
```jldoctest

0 commit comments

Comments
 (0)