We start by programming a class that has no external dependencies, the TimeStamp. We will use this class to indicate dates and times together in a single string in the format YYYY-MM-DD-HH-mm, where MM means month and mm means minutes. As you can see, with one of these strings you have the information time and date, and it will be stored with the data we retrieve from time-series for analysis in Chapter 9, Implementing an Efficient Simple Moving Average.
Our TimeStamp class will be implemented using S3. As you can see, we include the lubridate package to do some heavy lifting for us when transforming dates, and provide a constructor that checks whether or not the string being passed is a valid timestamp:
library(lubridate)
timestamp_constructor <- function(timestamp = now.TimeStamp()) {
class(timestamp) <- "TimeStamp...