Skip to content

Commit

Permalink
Truncate timestamps to milliseconds (#468)
Browse files Browse the repository at this point in the history
Fixes #444
  • Loading branch information
evetion authored Aug 1, 2023
1 parent 7db4489 commit 37ecef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion core/src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ function load_structvector(
if table isa Query && haskey(nt, :time)
# time has type timestamp and is stored as a String in the GeoPackage
# currently SQLite.jl does not automatically convert it to DateTime
nt = merge(nt, (; time = DateTime.(nt.time, dateformat"yyyy-mm-dd HH:MM:SS.s")))
nt = merge(
nt,
(;
time = DateTime.(
replace.(nt.time, r"(\.\d{3})\d+$" => s"\1"), # remove sub ms precision
dateformat"yyyy-mm-dd HH:MM:SS.s",
)
),
)
end

table = StructVector{T}(nt)
Expand Down
3 changes: 2 additions & 1 deletion python/ribasim_testmodels/ribasim_testmodels/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ def tabulated_rating_curve_model() -> ribasim.Model:
data={
"node_id": [3, 3, 3, 3, 3, 3],
"time": [
pd.Timestamp("2020-01"),
# test subsecond precision
pd.Timestamp("2020-01-01 00:00:00.000001"),
pd.Timestamp("2020-01"),
pd.Timestamp("2020-02"),
pd.Timestamp("2020-02"),
Expand Down

0 comments on commit 37ecef0

Please sign in to comment.