Skip to content

Commit addf97b

Browse files
committed
simplifiy and rebuild overview vignette
1 parent d18a1cd commit addf97b

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

vignettes/overview.Rmd

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,20 @@ abline( v = trunc(dateSeq[1], units = "days") + c(sunrise,sunset)*3600L )
159159
```
160160

161161
Function `getHoursAheadOfUTC` provides the integer timeZone argument
162-
of a timestamp, required other functions of the package.
162+
of a timestamp, required by other functions of the package.
163163
Similarly, `getFractionalHours` provides fractional hours after midnight of
164164
a timestamp.
165165

166166
```{r}
167167
#around daylight saving time step in Central European time
168-
tzBack <- Sys.getenv("TZ"); Sys.setenv(TZ = "Europe/Berlin")
169-
t1 <- as.POSIXct("2018-10-28 01:30")
170-
(dateSeq <- seq(t1, by = "30 min", length.out = 6))
171-
(hoursAhead <- getHoursAheadOfUTC(dateSeq))
172-
(facHours <- getFractionalHours(dateSeq))
173-
Sys.setenv(TZ = tzBack)
168+
t1 <- as.POSIXct("2018-10-28 01:30", tz = "Europe/Berlin")
169+
datesCET <- seq(t1, by = "30 min", length.out = 6)
170+
datesUTC <- as.POSIXct(datesCET, tz = "UTC")
171+
#
172+
hoursAheadOfUTC <- getHoursAheadOfUTC(datesCET)
173+
fracHours <- getFractionalHours(datesCET)
174+
#
175+
data.frame(datesUTC, datesCET, hoursAheadOfUTC, fracHours)
174176
```
175177

176178
<!--

vignettes/overview.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,19 @@ a timestamp, required other functions of the package. Similarly,
135135
timestamp.
136136

137137
#around daylight saving time step in Central European time
138-
tzBack <- Sys.getenv('TZ'); Sys.setenv(TZ = "Europe/Berlin")
139-
t1 <- as.POSIXct("2018-10-28 01:30")
140-
(dateSeq <- seq(t1, by = "30 min", length.out = 6))
141-
142-
## [1] "2018-10-28 01:30:00 CEST" "2018-10-28 02:00:00 CEST" "2018-10-28 02:30:00 CEST" "2018-10-28 02:00:00 CET" "2018-10-28 02:30:00 CET" "2018-10-28 03:00:00 CET"
143-
144-
(hoursAhead <- getHoursAheadOfUTC(dateSeq))
145-
146-
## [1] 2 2 2 1 1 1
147-
148-
(facHours <- getFractionalHours(dateSeq))
149-
150-
## [1] 1.5 2.0 2.5 3.0 3.5 4.0
151-
152-
Sys.setenv(TZ = tzBack)
138+
t1 <- as.POSIXct("2018-10-28 01:30", tz = "Europe/Berlin")
139+
dateSeq <- seq(t1, by = "30 min", length.out = 6)
140+
hoursAheadOfUTC <- getHoursAheadOfUTC(dateSeq)
141+
fracHours <- getFractionalHours(dateSeq)
142+
data.frame(dateSeq, hoursAheadOfUTC, fracHours)
143+
144+
## dateSeq hoursAheadOfUTC fracHours
145+
## 1 2018-10-28 01:30:00 2 1.5
146+
## 2 2018-10-28 02:00:00 2 2.0
147+
## 3 2018-10-28 02:30:00 2 2.5
148+
## 4 2018-10-28 02:00:00 1 3.0
149+
## 5 2018-10-28 02:30:00 1 3.5
150+
## 6 2018-10-28 03:00:00 1 4.0
153151

154152
<!--
155153
See the [package vignettes](https://github.com/bgctw/solartime/tree/master/vignettes) (*.md) for further examples.

0 commit comments

Comments
 (0)