timer with a startat datetime variable in a different time zone

I would like to schedule a task described in 'dummy_script' at e.g. 8:00 am New York time. I do not live in the US but for convenience (daylight saving changes,...) I would like to use New York time as my reference point for my 'startat' time (trigger1) to make sure it always trigger at 8:00 am NY time.
trigger1 = datetime(2020,10,8,8,00,0,'TimeZone','America/New_York')
This is my simple timer function:
t = timer;
t.TimerFcn = @(~,~) dummy_script1;
startat(t,trigger2)
The only way I can make this work is by defining trigger1 as specified above and then converting it to my local time zone before I use it as a reference point:
trigger2.TimeZone = 'local'
Is there a more elegant way of having Matlab recognise and consider the time zone set for trigger1?

回答 (1 件)

Seth Furman
Seth Furman 2020 年 10 月 28 日

0 投票

Thank you for reporting this issue. Unfortunately, the startat function currently ignores timezone information when a zoned datetime is provided. I've logged this issue and it may be addressed in a future release. In the meantime, datetime values not in the local timezone will have to be converted to the local timezone before calling startat.

カテゴリ

ヘルプ センター および File Exchange で Audio Processing Algorithm Design についてさらに検索

質問済み:

2020 年 10 月 7 日

回答済み:

2020 年 10 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by