timer with a startat datetime variable in a different time zone

조회 수: 3 (최근 30일)
Damian Maxwell
Damian Maxwell 2020년 10월 7일
답변: Seth Furman 2020년 10월 28일
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일
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.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by