Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
694f9103
Commit
694f9103
authored
11 months ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
AnnualDates can be instantiated from strings
parent
0d30cead
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/utils.jl
+4
-0
4 additions, 0 deletions
src/core/utils.jl
src/world/landscape.jl
+1
-1
1 addition, 1 deletion
src/world/landscape.jl
test/io_tests.jl
+6
-1
6 additions, 1 deletion
test/io_tests.jl
with
11 additions
and
2 deletions
src/core/utils.jl
+
4
−
0
View file @
694f9103
...
...
@@ -47,6 +47,10 @@ end
AnnualDate
(
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
...
)
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
)
# allow creating AnnualDates from a string of the format "8 August"
AnnualDate
(
ad
::
String
)
=
AnnualDate
(
Date
(
ad
,
dateformat
"d U"
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
String
)
=
AnnualDate
(
ad
)
# Interface with Dates
AnnualDate
(
date
::
Date
)
=
AnnualDate
(
month
(
date
),
day
(
date
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Date
)
=
AnnualDate
(
ad
)
...
...
This diff is collapsed.
Click to expand it.
src/world/landscape.jl
+
1
−
1
View file @
694f9103
This diff is collapsed.
Click to expand it.
test/io_tests.jl
+
6
−
1
View file @
694f9103
...
...
@@ -113,11 +113,16 @@ end
@test
1
km
/
5
==
200
m
# AnnualDates
birthday
::
AnnualDate
=
(
August
,
21
)
christmas
::
AnnualDate
=
(
December
,
24
)
christmas
::
AnnualDate
=
"24
December
"
heute
=
Date
(
2024
,
8
,
8
)
@test
christmas
-
birthday
==
Day
(
125
)
@test
birthday
-
christmas
==
Day
(
240
)
@test
birthday
>
heute
@test
heute
+
Week
(
2
)
-
Day
(
1
)
==
birthday
@test
length
(
AnnualDate
(
heute
)
:
birthday
)
==
14
# bounds
@test
Ps
.
bounds
(
3
)
==
3
@test
Ps
.
bounds
(
-
3
)
==
0
@test
Ps
.
bounds
(
20
,
max
=
10
)
==
10
@test
Ps
.
bounds
(
-
3
,
min
=-
10
)
==
-
3
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment