Rank: 2843 based on 38 downloads (last 30 days) and 1 file submitted
photo

Erwin Mayer

E-mail

Personal Profile:

 

Watch this Author's files

 

Files Posted by Erwin Mayer
Updated   File Tags Downloads
(last 30 days)
Comments Rating
16 Dec 2014 Screenshot Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer local time, communications, gmt, time zone, time zones, travel 38 22
  • 4.125
4.1 | 8 ratings
Comments and Ratings by Erwin Mayer View all
Updated File Comments Rating
27 Mar 2013 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer

Hello Scott, I would be happy to help more, unfortunately I don't have Matlab installed right now, and I would greatly suggest to use the Joda Time library instead, to perform the same task as in my original script:
http://joda-time.sourceforge.net/
I have been using the C# port Noda Time lately and it is perfectly suited for this kind of tasks.

@Benjamin, this library would also be more reliable to avoid the kind of rounding errors you have observed.

22 Mar 2013 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer

Scott: Yes, it requires the financial toolbox.

04 Aug 2011 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer

Hi Justinas, it should adjust historical time for the DST, that was the purpose. At least provided the functions from the Java package support them (probably not for dates very far away) Let me know if it does not work with a special case.

07 Jul 2010 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer

Hi K E, from what I could see these functions are normally part of the Financial Toolbox. Aren't they enabled by default?

21 Jun 2010 World Time Zones Convert between local time and UTC. Get local time in various places in the world. Author: Bill McKeeman

Hello,

I have written a timezone converter that takes into account DST.
Check it out here: http://www.mathworks.com/matlabcentral/fileexchange/27953

It makes use of the Calendar Class in Java.

Comments and Ratings on Erwin Mayer's Files View all
Updated File Comment by Comments Rating
03 Dec 2014 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer Matt Fifer

I incorrectly added one to the milliseconds below, they need to be rounded instead:

t1.set(Calendar.MILLISECOND, round((S - fix(S)) * 1000));

03 Dec 2014 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer Matt Fifer

Thanks for providing this function, Erwin! One quick thing: the set function used does not support milliseconds, so those have to be set manually. To fix this issue (and keeping the Financial Toolbox dependency fix from Scott below), the t1.set... line in the current code has to be replaced with the following lines:

[Y, M, D, H, MN, S] = datevec(dn);
t1.set(Y, M-1, D, H, MN, S);
t1.set(Calendar.MILLISECOND, (S - fix(S)) * 1000 + 1);

otherwise, it seems like milliseconds get set to a random number.

29 Oct 2014 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer Alex

Thanks

26 Dec 2013 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer Ricardo

Here's a suggestion for a vectorized version of this function:

function time = convertTZone(time, TZoneOld, TZoneNew)

OffSet = now - TimezoneConvert(now, TZoneOld, TZoneNew);
time = time - OffSet;

end

10 Oct 2013 Convert between world time zones with daylight saving times This is a very simple yet powerful function to convert a datenum from one timezone to another. Author: Erwin Mayer Dennis Wouters

@Scott, I applied your 'fix', but do not observe your issue.

t1 = datestr(TimezoneConvert(datenum('31-Mar-2013 00:59:59'),'UTC','Europe/Berlin'))
t2 = datestr(TimezoneConvert(datenum('31-Mar-2013 01:00:00'),'UTC','Europe/Berlin'))

Results in:
t1 =
31-Mar-2013 01:59:59
t2 =
31-Mar-2013 03:00:00

as expected.
So I think your fix is ok.

Contact us