From 62052bf26dab29168335ba3483830284167c7a07 Mon Sep 17 00:00:00 2001 From: Paolo Oliveira Date: Tue, 9 Jul 2024 15:10:39 +0100 Subject: [PATCH] #10471 Update set_time opetion | WIP --- lib/devices/set_system_date_and_time.ex | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/devices/set_system_date_and_time.ex b/lib/devices/set_system_date_and_time.ex index 12c7216..41433bc 100644 --- a/lib/devices/set_system_date_and_time.ex +++ b/lib/devices/set_system_date_and_time.ex @@ -13,6 +13,13 @@ defmodule Onvif.Devices.SetSystemDateAndTime do end def request_body(%SystemDateAndTime{} = system_date_time) do + request_body([config: system_date_time, set_time?: false]) + end + + #def request_body(%SystemDateAndTime{} = system_date_time, opts) do + def request_body([config: %SystemDateAndTime{} = system_date_time] = opts) do + IO.inspect(opts) + set_time? = Keyword.get(opts, :set_time?, false) element(:"s:Body", [ element(:"tds:SetSystemDateAndTime", [ element(:"tds:DateAndTime", system_date_time.date_time_type ), @@ -23,7 +30,13 @@ defmodule Onvif.Devices.SetSystemDateAndTime do element(:"tt:TZ", system_date_time.time_zone.tz ) ] ), + List.flatten([utc_date_time_element(system_date_time, set_time?)]) + ]) + ]) + end + def utc_date_time_element(system_date_time, false) do [] end + def utc_date_time_element(system_date_time, true) do element( :"tds:UTCDateTime", [ @@ -39,9 +52,6 @@ defmodule Onvif.Devices.SetSystemDateAndTime do ]) ] ) - - ]) - ]) end def response(xml_response_body) do