Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhuijzer authored and johanmon committed Jul 5, 2021
1 parent 4a4ce27 commit bbc6912
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions stdlib/Dates/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,23 @@ julia> dt2 = Date("2015-01-02",df)
2015-01-02
```

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.
Alternatively, use broadcasting:

```jldoctest
julia> years = string.(2000:10000);
julia> years = ["2015", "2016"];
julia> Date.(years, DateFormat("yyyy"))
2-element Vector{Date}:
2015-01-01
2016-01-01
```

julia> dates = Date.(years, dateformat"yyyy");
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.

julia> dates[1:3]
3-element Vector{Date}:
2000-01-01
2001-01-01
2002-01-01
```jldoctest
julia> for i = 1:10^5
Date("2015-01-01", dateformat"y-m-d")
end
```

As well as via the constructors, a `Date` or `DateTime` can be constructed from
Expand Down

0 comments on commit bbc6912

Please sign in to comment.