Ronny Steen
2015-Nov-22 10:52 UTC
[R] Converting time zones in R using metadata file information of video files, help needed.
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 find working with different time-zones to be difficult, I hope I managed to formulate an understandable question. Regards, Kes [[alternative HTML version deleted]]
David Winsemius
2015-Nov-22 20:54 UTC
[R] Converting time zones in R using metadata file information of video files, help needed.
> 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
Law, Jason
2015-Nov-23 17:51 UTC
[R] Converting time zones in R using metadata file information of video files, help needed.
The "lubridate" package will help simplify these time zone conversions. It provides two simple functions with_tz and force_tz that conceptually make things simpler. library(lubridate)> x <- as.POSIXct("2015-06-22 01:53:28", 'Europe/Berlin') > with_tz(x, 'America/Toronto')[1] "2015-06-21 19:53:28 EDT" HTH, J -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ronny Steen Sent: Sunday, November 22, 2015 2:52 AM To: r-help at r-project.org Subject: [R] Converting time zones in R using metadata file information of video files, help needed. 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 find working with different time-zones to be difficult, I hope I managed to formulate an understandable question. 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.