[R] Converting time zones in R using metadata file information of video files, help needed.

David Winsemius dwinsemius at comcast.net
Sun Nov 22 21:54:33 CET 2015


> On Nov 22, 2015, at 2:52 AM, Ronny Steen <kestrel1978 at gmail.com> wrote:
> 
> Hi,
> 
> I have video files (FAT) that are taken in a different timezone than my
> current location. The modification date/time in the metafila data of the
> video file shows the time video was taken, although in the current timezone
> of my computer, if I understand right.
> 
> I wish to convert the date/time to the origin. The video was taken in
> London, Ontario Canada at 2015-06-21 07:53:28, when looking at the metadata
> of the file on my computer (timezone "Europe/Berlin") it says modification
> date "2015-06-22 01:53:28". Hence, there is a 6 hour difference between the
> two time-zones
> 
> I use the script provided here:
> http://blog.revolutionanalytics.com/2009/06/converting-time-zones.html
> 
> pb.txt <- "2015-06-22 01:53:28" #modification date as shown on my
> computer (timezone
> "Europe/Berlin")
> 
> pb.date <- as.POSIXct(pb.txt, tz="Europe/London")
> 
> pb.date <- as.POSIXct(pb.txt, tz="America/Toronto")#timezone of origin
> video camera location
> 
> format(pb.date, tz=local.time,usetz=TRUE) #formats the mtime to data and
> time when the video was taken
> 
> [1] "2015-06-22 07:53:28 CEST" # the time is correct but the date is wrong
> as it has added 6 hours rather than subtracting.

I don’t understand why that is not the correct calculation, since the Sun rises in the East and so the local time is “later” in Berlin than in Toronto. When it is later in the day in a more Westerly TZ the calculations on dates are correct>

> pb.txt <- "2015-06-22 21:53:28"

> pb.date <- as.POSIXct(pb.txt)
> pb.date
[1] "2015-06-22 21:53:28 PDT"

> format( pb.date, tz="Europe/Berlin")
[1] "2015-06-23 06:53:28"
> 
> I find working with different time-zones to be difficult, I hope I managed
> to formulate an understandable question.

With R the timezomes are mainly useful for output (including `print`-ing results in the current locale) and the options on input are limited. The numeric value is always in GMT/UCT.


> 
> Regards,
> 
> Kes
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list