Skip to content

Commit fcf6e50

Browse files
authored
Structtypes (#13)
1 parent 658acc2 commit fcf6e50

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "UnixTimes"
22
uuid = "ab1a18e7-b408-4913-896c-624bb82ed7f4"
33
authors = ["Christian Rorvik <christian.rorvik@gmail.com>"]
4-
version = "1.6.0"
4+
version = "1.7.0"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -10,9 +10,11 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1010
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
1111
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
1212
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
13+
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
1314

1415
[extensions]
1516
UnixTimesMakieExt = ["Makie", "Observables"]
17+
UnixTimesStructTypesExt = "StructTypes"
1618
UnixTimesTimeZonesExt = "TimeZones"
1719

1820
[compat]

ext/UnixTimesStructTypesExt.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module UnixTimesStructTypesExt
2+
3+
using Dates
4+
using StructTypes
5+
using UnixTimes
6+
7+
StructTypes.StructType(::Type{UnixTime}) = StructTypes.CustomStruct()
8+
StructTypes.lower(x::UnixTime) = Dates.value(x)
9+
StructTypes.lowertype(::Type{UnixTime}) = Int64
10+
StructTypes.construct(::Type{UnixTime}, x::Int64) =
11+
UnixTime(Dates.UTInstant(Dates.Nanosecond(x)))
12+
13+
end

0 commit comments

Comments
 (0)