Skip to content

Commit

Permalink
[15.4.7-rc7] use iso8601 in datetime lua helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed May 2, 2024
1 parent 5e3e4cb commit 082af7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.4.7-rc6
15.4.7-rc7
4 changes: 2 additions & 2 deletions lib/os/lua/info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ defmodule FarmbotOS.Lua.Info do
def utc(["hour"], lua), do: {[utc_p().hour], lua}
def utc(["minute"], lua), do: {[utc_p().minute], lua}
def utc(["second"], lua), do: {[utc_p().second], lua}
def utc(_, lua), do: {[DateTime.to_string(utc_p())], lua}
def utc(_, lua), do: {[DateTime.to_iso8601(utc_p())], lua}

def local_time(["year"], lua), do: {[local_time_p().year], lua}
def local_time(["month"], lua), do: {[local_time_p().month], lua}
def local_time(["day"], lua), do: {[local_time_p().day], lua}
def local_time(["hour"], lua), do: {[local_time_p().hour], lua}
def local_time(["minute"], lua), do: {[local_time_p().minute], lua}
def local_time(["second"], lua), do: {[local_time_p().second], lua}
def local_time(_, lua), do: {[DateTime.to_string(local_time_p())], lua}
def local_time(_, lua), do: {[DateTime.to_iso8601(local_time_p())], lua}

defp utc_p() do
DateTime.utc_now()
Expand Down
4 changes: 2 additions & 2 deletions test/os/lua/ext/info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ defmodule FarmbotOS.Lua.InfoTest do

test "utc()" do
utc = DateTime.utc_now()
now = String.slice(DateTime.to_string(utc), 0..15)
now = String.slice(DateTime.to_iso8601(utc), 0..15)
lua_code = "return utc()"
{:ok, [actual]} = lua(lua_code, lua_code)
assert String.starts_with?(actual, now)
Expand Down Expand Up @@ -171,7 +171,7 @@ defmodule FarmbotOS.Lua.InfoTest do
test "local_time()" do
tz = "America/Chicago"
local = Timex.Timezone.convert(DateTime.utc_now(), tz)
now = String.slice(DateTime.to_string(local), 0..15)
now = String.slice(DateTime.to_iso8601(local), 0..15)
lua_code = "return local_time()"
{:ok, [actual]} = lua(lua_code, lua_code)
assert String.starts_with?(actual, now)
Expand Down

0 comments on commit 082af7d

Please sign in to comment.