From 72cf4c21123821e59389debdd1920cf4b4e6c10c Mon Sep 17 00:00:00 2001 From: Dan Taras Date: Thu, 20 Oct 2022 16:58:50 +0200 Subject: [PATCH 1/2] Construct from Date and Time --- Project.toml | 2 +- src/UnixTimes.jl | 2 ++ test/runtests.jl | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fbe543d..6779966 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnixTimes" uuid = "ab1a18e7-b408-4913-896c-624bb82ed7f4" authors = ["Christian Rorvik "] -version = "1.2.0" +version = "1.2.1" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/UnixTimes.jl b/src/UnixTimes.jl index 01ddf99..92cec68 100644 --- a/src/UnixTimes.jl +++ b/src/UnixTimes.jl @@ -61,6 +61,8 @@ function UnixTime(x::DateTime) end UnixTime(x::Date) = UnixTime(DateTime(x)) +UnixTime(x::Date, y::Time) = + UnixTime(year(x), month(x), day(x), hour(y), minute(y), second(y), millisecond(y), microsecond(y), nanosecond(y)) Base.convert(::Type{UnixTime}, x::DateTime) = UnixTime(x) diff --git a/test/runtests.jl b/test/runtests.jl index e464b55..b6769fb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -84,6 +84,7 @@ end @test Date(UnixTime(2020, 1, 2, 3)) == Date(2020, 1, 2) @test Time(UnixTime(2020, 1, 2, 3, 4, 5, 6, 7, 8)) == Time(3, 4, 5, 6, 7, 8) @test UnixTime(Date(2020, 1, 2)) == UnixTime(2020, 1, 2) + @test UnixTime(Date(2020, 1, 2), Time(3, 4, 5, 6, 7, 8)) == UnixTime(2020, 1, 2, 3, 4, 5, 6, 7, 8) @test convert(UnixTime, DateTime(2020, 1, 2, 3)) == UnixTime(2020, 1, 2, 3) @test convert(DateTime, UnixTime(2020, 1, 2, 3)) == DateTime(2020, 1, 2, 3) @test UnixTime(ZonedDateTime(2020, 1, 2, 3, tz"UTC-4")) == UnixTime(2020, 1, 2, 7) From 5835f83ad951053f3df9ed5d385f20b44b3ee8b2 Mon Sep 17 00:00:00 2001 From: dantaras <47561995+dantaras@users.noreply.github.com> Date: Thu, 20 Oct 2022 17:37:36 +0200 Subject: [PATCH 2/2] Update Project.toml Co-authored-by: Christian Rorvik --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6779966..02d24cb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnixTimes" uuid = "ab1a18e7-b408-4913-896c-624bb82ed7f4" authors = ["Christian Rorvik "] -version = "1.2.1" +version = "1.3.0" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"