Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
MichelJuillard
Periods.jl
Commits
2d00ed14
Commit
2d00ed14
authored
Mar 09, 2020
by
Michel Juillard
Browse files
add operations
parent
6fc8e70e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Periods.jl
View file @
2d00ed14
...
...
@@ -5,4 +5,15 @@ abstract type AbstractPeriod end
include
(
"SimplePeriods.jl"
)
export
Frequency
,
Period
,
Year
,
Semester
,
Quarter
,
Month
,
Week
,
Day
,
Undated
import
Base
.:-
-
(
p1
::
AbstractPeriod
,
p2
::
AbstractPeriod
)
=
p1
.
ordinal
-
p2
.
ordinal
import
Base
.:>
>
(
p1
::
AbstractPeriod
,
p2
::
AbstractPeriod
)
=
p1
.
ordinal
>
p2
.
ordinal
import
Base
.:<
<
(
p1
::
AbstractPeriod
,
p2
::
AbstractPeriod
)
=
p1
.
ordinal
<
p2
.
ordinal
import
Base
.
checkindex
checkindex
(
::
Type
{
Bool
},
inds
::
AbstractUnitRange
,
p
::
AbstractPeriod
)
=
checkindex
(
Bool
,
inds
,
p
.
ordinal
)
end
# module
src/SimplePeriods.jl
View file @
2d00ed14
...
...
@@ -46,3 +46,11 @@ end
Period
(
year
::
Integer
,
month
::
Integer
,
day
::
Integer
)
=
(
Date
(
year
,
month
,
day
)
.
value
,
Day
)
Period
(
d
::
Date
)
=
(
d
.
value
,
Day
)
import
Base
.
copy
copy
(
p
::
Period
)
=
Period
(
p
.
ordinal
,
p
.
frequency
)
import
Base
.:+
+
(
p1
::
Period
,
k
::
Integer
)
=
Period
(
p1
.
ordinal
+
k
,
p1
.
frequency
)
import
Base
.:-
-
(
p1
::
Period
,
k
::
Integer
)
=
Period
(
p1
.
ordinal
-
k
,
p1
.
frequency
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment