Purpose
To work through case study I of the lubridate package.

We can add 10 months to the date easily

> date <- ymd("2010-01-01")
> month(date) <- 11
> date
[1] "2010-11-01 UTC"

Check which day the date falls

> wday(date, label = T, abbr = F)
[1] Monday
7 Levels: Sunday < Monday < Tuesday < Wednesday < Thursday < ... < Saturday
> wday(date, label = F, abbr = F)
[1] 2

Add three days

> wday(date + days(3), label = T, abbr = F)
[1] Thursday
7 Levels: Sunday < Monday < Tuesday < Wednesday < Thursday < ... < Saturday

Add three weeks

> wday(date + weeks(3), label = T, abbr = F)
[1] Monday
7 Levels: Sunday < Monday < Tuesday < Wednesday < Thursday < ... < Saturday

Futures Expiry date happens on the last thursday of a month

> date <- now()
> d <- wday(ceiling_date(date, "month") - days(1))
> correction <- 0
> days(d - 4)
[1] -3 days
> ceiling_date(date, "month") - days(1) + correction
[1] "2011-07-31 IST"