lubidate for tesla powerwall date conversion

Tesla Powerwall data is recorded in 5 minute intervals. The date format is presented as a character string with date and time separated by a "T" and timezone added as "+12:00", aka NZST, an example of which looks like this: "2022-12-23T00:00:00+13:00".

I have attempted separating date and time using separate after a str_replace "T" with a space " ", but after that, nothing much worked without an "Error in mutate():".

Any suggestions for the best way to process the date and time in a data table.

Thanks
Charles

What exactly is your goal? I can change your example string to a datetime value with ymd_hms().

library(lubridate)
ymd_hms("2022-12-23T00:00:00+13:00")
[1] "2022-12-22 11:00:00 UTC"
2 Likes

If the timezone needs to be captured

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
ymd_hms("2022-12-23T00:00:00+13:00",tz = "Pacific/Auckland")
#> Date in ISO8601 format; converting timezone from UTC to "Pacific/Auckland".
#> [1] "2022-12-23 NZDT"

Created on 2022-12-30 by the reprex package (v2.0.1)

1 Like

Thanks for the example. I manage to make things more complex than needed. My intention is to use the data table to analyse the house demand, seasonal solar production and visualise the data in ggplot().

Once the date is formatted, I can aggregate diurnal trends and generate a heat map.

All the best for 2023.

Thanks Richard, the timezone isn't needed if data is analysed locally, but having time correctly formatted allows data to be compared to regional data. Using ymd_hms("2022-12-23T00:00:00+13:00"), data can be mutated into variables of date and time.

Thank you very much for your support.

All the best, Charles

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.