Timezone to UTC: How do I add duration vector to datetime vector?
Afficher commentaires plus anciens
I want to use the new tzoffset (r2014b+) to make a function to change a datenum time vector to UTC timezone but I've encountered a strange behavior while doing operations on a datetime vector. I would like to know if I'm missing something here.
time=['2015/03/08 00:00';'2015/03/08 01:00';'2015/03/08 03:00';'2015/03/08 04:00'];
Time=datenum(time,'yyyy/mm/dd HH:MM')
date=datetime(Time,'ConvertFrom','datenum','Timezone','America/Montreal')
[UTC_Offset,dst]=tzoffset(date)
Date=date-UTC_Offset
Should give
08-Mar-2015 05:00:00
08-Mar-2015 06:00:00
08-Mar-2015 07:00:00
08-Mar-2015 08:00:00
But there's 1 extra hour being added before the daylight saving time change.
08-Mar-2015 06:00:00
08-Mar-2015 07:00:00
08-Mar-2015 07:00:00
08-Mar-2015 08:00:00
The same behavior is present when doing:
date(1)+duration(5,0,0)
So I believe something is up with the datetime vector. Does anybody else get this or I just did something wrong?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!