-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,7 +476,6 @@ Missing in AstroLib.jl | |
* `xy2ad` | ||
* `xyad` | ||
* `xyxy` | ||
* `ydn2md` | ||
* `zang` | ||
* `zbrent` | ||
* `zenpos` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This file is a part of AstroLib.jl. License is MIT "Expat". | ||
# Copyright (C) 2016 Mosè Giordano. | ||
|
||
""" | ||
ydn2md(year, day) -> date | ||
### Purpose ### | ||
Convert from year and day number of year to a date. | ||
### Explanation ### | ||
Returns the date corresponding to the `day` of `year`. | ||
### Arguments ### | ||
* `year`: the year, as a scalar integer. | ||
* `day`: the day of `year`, as an integer. It is can be either a scalar or | ||
array of integers. | ||
### Output ### | ||
The date, of `Date` type, of \$\text{day} - 1\$ days after January 1st of | ||
`year`. | ||
### Example ### | ||
Find the date of the 60th and 234th days of the year 2016. | ||
``` julia | ||
julia> ydn2md(2016, [60, 234]) | ||
2-element Array{Date,1}: | ||
2016-02-29 | ||
2016-08-21 | ||
``` | ||
### Note ### | ||
`ymd2dn` converts from a date to day of the year. | ||
""" | ||
function ydn2md(year::Integer, day::Integer) | ||
return Dates.firstdayofyear(Date(year)) + Dates.Day(day - 1) | ||
end | ||
|
||
function ydn2md{D<:Integer}(year::Integer, days::AbstractArray{D}) | ||
dates = similar(days, Date) | ||
for d in eachindex(days) | ||
dates[d] = ydn2md(year, days[d]) | ||
end | ||
return dates | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters