Lamma I/O

Heads up! These docs are for v1.1.3, which is no longer officially supported. Check out the latest version of Lamma!

Lamma Date

As a by product, io.lamma.Date is very convenient to use in date processing, though timestamp (hh, mm, ss) and timezone are not supported. Here are some examples, for all usages please check API Doc.

scala -cp lamma_2.11-1.1.jar   // there is no external dependencies for lamma, very REPL friendly

Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import io.lamma.Date
import io.lamma.Date

scala> Date(2015, 5, 5) + 2     // plus days by int
res0: io.lamma.Date = Date(2015,5,7)

scala> Date(2015, 5, 5) - 2     // minus days by int
res1: io.lamma.Date = Date(2015,5,3)

scala> Date(2015, 5, 15) - Date(2015, 5, 8)   // minus two days => difference between two days
res2: Int = 7

scala> Date(2015, 5, 20) > Date(2015, 5, 17)    // greater than sign can be used directly
res3: Boolean = true

scala> Date(2015, 5, 20) <= Date(2015, 5, 17)   // and less than or equal sign
res4: Boolean = false

// with this implicit conversion, we can make more use of + / - operator
scala> import io.lamma.Duration._
import io.lamma.Duration._

scala> Date(2015, 5, 5) + (1 month)     // plus one month, remember to add the bracket
res6: io.lamma.Date = Date(2015,6,5)

scala> Date(2015, 5, 5) + (6 weeks)     // plus 6 weeks, remember to add the bracket
res7: io.lamma.Date = Date(2015,6,16)

scala> Date(2015, 6, 8) + (10 years) + (7 months) + (3 weeks) + (5 days)  // more complicated example
res8: io.lamma.Date = Date(2026,2,3)

scala> import io.lamma.Weekday.Friday
import io.lamma.Weekday.Friday

scala> Date(2015, 6, 3).nextWeekday(Friday)  // find next weekday
res9: io.lamma.Date = Date(2015,6,5)

scala> Date(2015, 7, 7) to Date(2015, 7, 10) foreach println    // date range
Date(2015,7,7)
Date(2015,7,8)
Date(2015,7,9)
Date(2015,7,10)