Skip to content

Commit

Permalink
meta
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterLuschny committed Feb 17, 2022
1 parent 115e788 commit 3647a6a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Calendars"
uuid = "2e69b1bb-2c9c-41e6-ab4b-04f4c0f206b8"
authors = ["PeterLuschny"]
version = "0.6.4"
version = "0.6.5"

# In fact "Calendars" is independent of "Dates".
# It only uses the line "using Dates: yearmonthday, now"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Registered on [JuliaHub](https://juliahub.com/ui/Packages/Calendars/yDHMq), read
# Calendars, Conversions of Dates, Change of Calendars


The package _Calendar_ provides a Julia implementation of six calendars and two day numbers:
The package _Calendars.jl_ provides a Julia implementation of six calendars and two day numbers:

| Enum | Acronym | Calendar |
| :-: | :---: | :--- |
Expand Down
73 changes: 47 additions & 26 deletions notebook/Calendars.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "459812c0",
"metadata": {},
"outputs": [
Expand All @@ -49,7 +49,7 @@
"(4, 5516, 11, 25)"
]
},
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -76,7 +76,7 @@
}
],
"source": [
"ConvertDate(\"Gregorian\", 1756, 1, 27, \"Hebrew\")"
"ConvertDate(\"Gregorian\", 1756, 1, 27, \"Hebrew\", true)"
]
},
{
Expand Down Expand Up @@ -108,6 +108,27 @@
"DateFromDayNumber(\"Gregorian\", 641027)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f6eb9541",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"Common \""
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarName(2)"
]
},
{
"cell_type": "markdown",
"id": "f9aa5345-864e-48b6-8f43-6415da6b1e80",
Expand All @@ -118,7 +139,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "84008ebb",
"metadata": {},
"outputs": [
Expand All @@ -128,13 +149,13 @@
"\"EN#0641029\""
]
},
"execution_count": 7,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"DayNumberFromDate(\"CE\", 1756, 1, 27, true)"
"DayNumberFromDate(CE, 1756, 1, 27, true)"
]
},
{
Expand All @@ -147,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "07bbb3b3",
"metadata": {},
"outputs": [
Expand All @@ -157,7 +178,7 @@
"((1, 1756, 1, 27), (2, 1756, 1, 27), (3, 1756, 1, 16), (4, 5516, 11, 25), (5, 1169, 4, 24), (6, 1756, 5, 2), (7, 0, 0, 641029), (8, 0, 0, 2362452))"
]
},
"execution_count": 8,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -168,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "f54dfc8b",
"metadata": {},
"outputs": [
Expand All @@ -192,13 +213,13 @@
"((1, 1756, 1, 27), (2, 1756, 1, 27), (3, 1756, 1, 16), (4, 5516, 11, 25), (5, 1169, 4, 24), (6, 1756, 5, 2), (7, 0, 0, 641029), (8, 0, 0, 2362452))"
]
},
"execution_count": 9,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"CE\", 1756, 1, 27, true)"
"CalendarDates(CE, 1756, 1, 27, true)"
]
},
{
Expand All @@ -211,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 14,
"id": "d20730c4-b57c-436c-be78-f1ca7b4a9ead",
"metadata": {},
"outputs": [
Expand All @@ -234,13 +255,13 @@
"((1, 284, 8, 29), (2, 284, 8, 29), (3, 284, 8, 29), (4, 4044, 6, 29), (0, 0, 0, 0), (6, 284, 35, 5), (7, 0, 0, 103607), (8, 0, 0, 1825030))"
]
},
"execution_count": 10,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"JD\", 284, 8, 29, true)"
"CalendarDates(JD, 284, 8, 29, true)"
]
},
{
Expand All @@ -253,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"id": "46091db4-1f82-4a7d-9f25-2e82dc61de0b",
"metadata": {},
"outputs": [
Expand All @@ -277,13 +298,13 @@
"((1, 1582, 10, 15), (2, 1582, 10, 15), (3, 1582, 10, 5), (4, 5343, 7, 19), (5, 990, 9, 17), (6, 1582, 41, 5), (7, 0, 0, 577738), (8, 0, 0, 2299161))"
]
},
"execution_count": 11,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"CE\", 1582, 10, 15, true)"
"CalendarDates(CE, 1582, 10, 15, true)"
]
},
{
Expand All @@ -296,7 +317,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 16,
"id": "2f6af10f-4b78-43d7-b389-ce93e95cdba5",
"metadata": {},
"outputs": [
Expand All @@ -320,13 +341,13 @@
"((1, 622, 7, 16), (2, 622, 7, 19), (3, 622, 7, 16), (4, 4382, 5, 3), (5, 1, 1, 1), (6, 622, 29, 5), (7, 0, 0, 227017), (8, 0, 0, 1948440))"
]
},
"execution_count": 12,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"JD\", 622, 7, 16, true)"
"CalendarDates(JD, 622, 7, 16, true)"
]
},
{
Expand All @@ -339,7 +360,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 17,
"id": "f48190e1-6edd-459d-9e92-b47fbe372885",
"metadata": {},
"outputs": [
Expand All @@ -363,13 +384,13 @@
"((1, 1792, 9, 22), (2, 1792, 9, 22), (3, 1792, 9, 11), (4, 5553, 7, 6), (5, 1207, 2, 5), (6, 1792, 38, 6), (7, 0, 0, 654417), (8, 0, 0, 2375840))"
]
},
"execution_count": 13,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"CE\", 1792, 9, 22, true)"
"CalendarDates(CE, 1792, 9, 22, true)"
]
},
{
Expand All @@ -382,7 +403,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 18,
"id": "44587a06-6666-4a79-9983-4f63cb623ff8",
"metadata": {},
"outputs": [
Expand All @@ -406,13 +427,13 @@
"((1, 1969, 7, 20), (2, 1969, 7, 20), (3, 1969, 7, 7), (4, 5729, 5, 5), (5, 1389, 5, 5), (6, 1969, 29, 7), (7, 0, 0, 719000), (8, 0, 0, 2440423))"
]
},
"execution_count": 14,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CalendarDates(\"CE\", 1969, 7, 20, true)"
"CalendarDates(CE, 1969, 7, 20, true)"
]
},
{
Expand Down
27 changes: 13 additions & 14 deletions src/Calendars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ But the next two queries return 'false' and 'true', respectively.
```julia
julia> isValidDate(CE, 1900, 2, 29)
julia> isValidDate(JD, 1900, 2, 29)
````
```
"""
function isValidDate(d::CDate, warn=true)
calendar = d[1]
Expand Down Expand Up @@ -388,8 +389,7 @@ isValidDate((StringToSymbol(calendar), d[1], d[2], d[3]))
DayOfYear(date::CDate)
```
Return the ordinal of the day in the given calendar. Also known
as the 'ordinal date' relative to the epoch of the calendar.
Return the ordinal of the day in the given calendar. Also known as the 'ordinal date' relative to the epoch of the calendar.
```julia
julia> DayOfYear(EC, 1756, 1, 27)
Expand All @@ -406,11 +406,10 @@ of the year 1756 in the European calendar. The same day
is in the Hebrew calendar the 144-th day of the year:
```julia
ConvertDate(EC, 1756, 1, 27, AM) |> DayOfYear
julia> DayOfYear(ConvertDate(EC, 1756, 1, 27, AM))
```
If an error occurs 0 (representing the invalid day of the year)
is returned.
If an error occurs 0 (representing the invalid day of the year) is returned.
"""
function DayOfYear(date::CDate)
if ! isValidDate(date)
Expand Down Expand Up @@ -519,14 +518,14 @@ function ConvertOrdinalDate(num::DPart, from::DPart, to::DPart)
re = EuroNumToJulianNum(num)
elseif from == JN && to == EN
re = JulianNumToEuroNum(num)
#elseif from == EN && to == DN
# re = EuroNumToFixNum(num)
#elseif from == DN && to == EN
# re = FixNumToEuroNum(num)
#elseif from == DN && to == JN
# re = FixNumToJulianNum(num)
#elseif from == JN && to == DN
# re = JulianNumToFixNum(num)
elseif from == EN && to == DN
re = EuroNumToFixNum(num)
elseif from == DN && to == EN
re = FixNumToEuroNum(num)
elseif from == DN && to == JN
re = FixNumToJulianNum(num)
elseif from == JN && to == DN
re = JulianNumToFixNum(num)
else
@warn("Unknown ordinal date name: ", from, " ", to)
return InvalidDayNumber
Expand Down

0 comments on commit 3647a6a

Please sign in to comment.