Skip to content
Browse files

Support for all subclasses of ReadablePartial and their Properties

  • Loading branch information...
1 parent dad12e4 commit 04d94831e4f9e52294f5718e40c7daf8f56729ea Jorge Ortiz committed May 6, 2009
View
3 src/changes/changes.xml
@@ -16,7 +16,8 @@
see http://maven.apache.org/plugins/maven-changes-plugin/usage.html for full guide
-->
<release version="0.2-SNAPSHOT" date="" description="">
- <action dev="Jorge Ortiz" type="fix">Ordered[T] for subclasses of ReadableInstant and ReadableDuration</action>
+ <action dev="Jorge Ortiz" type="add">Support for all subclasses of ReadablePartial and their Properties</action>
+ <action dev="Barry Kaplan" type="add">Support for LocalDate and LocalTime, including static forwarders</action>
<action dev="Jorge Ortiz" type="add">Explicit return types for all implicits</action>
<action dev="Jorge Ortiz" type="add">Shorter methods for DateTimeFormatter, and a new parseOption method</action>
<action dev="Jorge Ortiz" type="add">"apply" method is now an alias for setCopy in DateTime.Property</action>
View
19 src/main/scala/org/scala_tools/time/Implicits.scala
@@ -19,6 +19,7 @@ package org.scala_tools.time
import java.util.Locale
import org.joda.time._
+import org.joda.time.base.{AbstractDateTime, AbstractInstant, AbstractPartial}
import org.joda.time.format.DateTimeFormatter
import org.joda.time.field.AbstractReadableInstantFieldProperty
@@ -42,22 +43,32 @@ trait IntImplicits {
}
trait JodaImplicits {
+ implicit def RichAbstractDateTime(dt: AbstractDateTime): RichAbstractDateTime = new RichAbstractDateTime(dt)
+ implicit def RichAbstractInstant(in: AbstractInstant): RichAbstractInstant = new RichAbstractInstant(in)
+ implicit def RichAbstractPartial(pt: AbstractPartial): RichAbstractPartial = new RichAbstractPartial(pt)
implicit def RichAbstractReadableInstantFieldProperty(pty: AbstractReadableInstantFieldProperty): RichAbstractReadableInstantFieldProperty =
new RichAbstractReadableInstantFieldProperty(pty)
implicit def RichChronology(ch: Chronology): RichChronology = new RichChronology(ch)
implicit def RichDateMidnight(dm: DateMidnight): RichDateMidnight = new RichDateMidnight(dm)
- implicit def RichLocalDate(ld: LocalDate): RichLocalDate = new RichLocalDate(ld)
- implicit def RichLocalTime(lt: LocalTime): RichLocalTime = new RichLocalTime(lt)
implicit def RichDateTime(dt: DateTime): RichDateTime = new RichDateTime(dt)
implicit def RichDateTimeFormatter(fmt: DateTimeFormatter): RichDateTimeFormatter = new RichDateTimeFormatter(fmt)
implicit def RichDateTimeProperty(pty: DateTime.Property): RichDateTimeProperty = new RichDateTimeProperty(pty)
implicit def RichDateTimeZone(zone: DateTimeZone): RichDateTimeZone = new RichDateTimeZone(zone)
implicit def RichDuration(dur: Duration): RichDuration = new RichDuration(dur)
implicit def RichInstant(in: Instant): RichInstant = new RichInstant(in)
+ implicit def RichLocalDate(ld: LocalDate): RichLocalDate = new RichLocalDate(ld)
+ implicit def RichLocalDateProperty(pty: LocalDate.Property): RichLocalDateProperty = new RichLocalDateProperty(pty)
+ implicit def RichLocalDateTime(dt: LocalDateTime): RichLocalDateTime = new RichLocalDateTime(dt)
+ implicit def RichLocalDateTimeProperty(pty: LocalDateTime.Property): RichLocalDateTimeProperty = new RichLocalDateTimeProperty(pty)
+ implicit def RichLocalTime(lt: LocalTime): RichLocalTime = new RichLocalTime(lt)
+ implicit def RichLocalTimeProperty(pty: LocalTime.Property): RichLocalTimeProperty = new RichLocalTimeProperty(pty)
+ implicit def RichPartial(pt: Partial): RichPartial = new RichPartial(pt)
+ implicit def RichPartialProperty(pty: Partial.Property): RichPartialProperty = new RichPartialProperty(pty)
implicit def RichPeriod(per: Period): RichPeriod = new RichPeriod(per)
implicit def RichReadableDateTime(dt: ReadableDateTime): RichReadableDateTime = new RichReadableDateTime(dt)
- implicit def RichReadableDuration[T <: ReadableDuration](dur: T): RichReadableDuration[T] = new RichReadableDuration[T](dur)
- implicit def RichReadableInstant[T <: ReadableInstant](in: T): RichReadableInstant[T] = new RichReadableInstant[T](in)
+ implicit def RichReadableDuration(dur: ReadableDuration): RichReadableDuration = new RichReadableDuration(dur)
+ implicit def RichReadableInstant(in: ReadableInstant): RichReadableInstant = new RichReadableInstant(in)
implicit def RichReadableInterval(in: ReadableInterval): RichReadableInterval = new RichReadableInterval(in)
+ implicit def RichReadablePartial(rp: ReadablePartial): RichReadablePartial = new RichReadablePartial(rp)
implicit def RichReadablePeriod(per: ReadablePeriod): RichReadablePeriod = new RichReadablePeriod(per)
}
View
22 src/main/scala/org/scala_tools/time/Imports.scala
@@ -24,24 +24,28 @@ object StaticForwarderImports extends StaticForwarderImports
trait Imports extends TypeImports with StaticForwarderImports with Implicits
trait TypeImports {
+ type Chronology = org.joda.time.Chronology
type DateTime = org.joda.time.DateTime
+ type DateTimeFormat = org.joda.time.format.DateTimeFormat
+ type DateTimeZone = org.joda.time.DateTimeZone
+ type Duration = org.joda.time.Duration
+ type Interval = org.joda.time.Interval
type LocalDate = org.joda.time.LocalDate
+ type LocalDateTime = org.joda.time.LocalDateTime
type LocalTime = org.joda.time.LocalTime
- type Interval = org.joda.time.Interval
- type Duration = org.joda.time.Duration
type Period = org.joda.time.Period
- type DateTimeZone = org.joda.time.DateTimeZone
- type Chronology = org.joda.time.Chronology
- type DateTimeFormat = org.joda.time.format.DateTimeFormat
+ type Partial = org.joda.time.Partial
}
trait StaticForwarderImports {
val DateTime = org.scala_tools.time.StaticDateTime
+ val DateTimeFormat = org.scala_tools.time.StaticDateTimeFormat
+ val DateTimeZone = org.scala_tools.time.StaticDateTimeZone
+ val Duration = org.scala_tools.time.StaticDuration
+ val Interval = org.scala_tools.time.StaticInterval
val LocalDate = org.scala_tools.time.StaticLocalDate
+ val LocalDateTime = org.scala_tools.time.StaticLocalDateTime
val LocalTime = org.scala_tools.time.StaticLocalTime
- val Interval = org.scala_tools.time.StaticInterval
- val Duration = org.scala_tools.time.StaticDuration
val Period = org.scala_tools.time.StaticPeriod
- val DateTimeZone = org.scala_tools.time.StaticDateTimeZone
- val DateTimeFormat = org.scala_tools.time.StaticDateTimeFormat
+ val Partial = org.scala_tools.time.StaticPartial
}
View
29 src/main/scala/org/scala_tools/time/RichAbstractPartial.scala
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import org.joda.time._
+import org.joda.time.base.AbstractPartial
+
+class RichAbstractPartial(underlying: AbstractPartial) extends Ordered[AbstractPartial] {
+ def fields = underlying.getFields
+ def fieldTypes = underlying.getFieldTypes
+ def values = underlying.getValues
+
+ override def compare(that: AbstractPartial): Int =
+ underlying.compareTo(that)
+}
View
2 src/main/scala/org/scala_tools/time/RichDateTimeProperty.scala
@@ -32,7 +32,7 @@ class RichDateTimeProperty(underlying: DateTime.Property) {
underlying.roundCeilingCopy
def round: DateTime =
underlying.roundHalfEvenCopy
-
+
def apply(value: Int): DateTime = underlying.setCopy(value)
def apply(text: String): DateTime = underlying.setCopy(text)
def apply(text: String, locale: Locale): DateTime =
View
5 src/main/scala/org/scala_tools/time/RichLocalDate.scala
@@ -1,4 +1,5 @@
/**
+ * Copyright 2009 Jorge Ortiz
* Copyright 2009 Barry Kaplan
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,5 +41,7 @@ class RichLocalDate(underlying: LocalDate) {
def withMonth(month: Int) = underlying.withMonthOfYear(month)
def withYear(year: Int) = underlying.withYear(year)
def withCentury(century: Int) = underlying.withCenturyOfEra(century)
- def withEra(era: Int) = underlying.withEra(era)
+ def withEra(era: Int) = underlying.withEra(era)
+
+ def interval = underlying.toInterval
}
View
40 src/main/scala/org/scala_tools/time/RichLocalDateProperty.scala
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import java.util.Locale
+import org.joda.time._
+
+class RichLocalDateProperty(underlying: LocalDate.Property) {
+ def localDate: LocalDate =
+ underlying.getLocalDate
+ def roundFloor: LocalDate =
+ underlying.roundFloorCopy
+ def roundCeiling: LocalDate =
+ underlying.roundCeilingCopy
+ def roundDown: LocalDate =
+ underlying.roundFloorCopy
+ def roundUp: LocalDate =
+ underlying.roundCeilingCopy
+ def round: LocalDate =
+ underlying.roundHalfEvenCopy
+
+ def apply(value: Int): LocalDate = underlying.setCopy(value)
+ def apply(text: String): LocalDate = underlying.setCopy(text)
+ def apply(text: String, locale: Locale): LocalDate =
+ underlying.setCopy(text, locale)
+}
View
54 src/main/scala/org/scala_tools/time/RichLocalDateTime.scala
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import org.joda.time._
+
+class RichLocalDateTime(underlying: LocalDateTime) {
+ def -(duration: ReadableDuration): LocalDateTime =
+ underlying.minus(duration)
+ def -(period: ReadablePeriod): LocalDateTime =
+ underlying.minus(period)
+ def -(builder: DurationBuilder): LocalDateTime =
+ underlying.minus(builder.underlying)
+ def +(duration: ReadableDuration): LocalDateTime =
+ underlying.plus(duration)
+ def +(period: ReadablePeriod): LocalDateTime =
+ underlying.plus(period)
+ def +(builder: DurationBuilder): LocalDateTime =
+ underlying.plus(builder.underlying)
+
+ def second: LocalDateTime.Property = underlying.secondOfMinute
+ def minute: LocalDateTime.Property = underlying.minuteOfHour
+ def hour: LocalDateTime.Property = underlying.hourOfDay
+ def day: LocalDateTime.Property = underlying.dayOfMonth
+ def week: LocalDateTime.Property = underlying.weekOfWeekyear
+ def month: LocalDateTime.Property = underlying.monthOfYear
+ def year: LocalDateTime.Property = underlying.year
+ def century: LocalDateTime.Property = underlying.centuryOfEra
+ def era: LocalDateTime.Property = underlying.era
+
+ def withSecond(second: Int) = underlying.withSecondOfMinute(second)
+ def withMinute(minute: Int) = underlying.withMinuteOfHour(minute)
+ def withHour(hour: Int) = underlying.withHourOfDay(hour)
+ def withDay(day: Int) = underlying.withDayOfMonth(day)
+ def withWeek(week: Int) = underlying.withWeekOfWeekyear(week)
+ def withMonth(month: Int) = underlying.withMonthOfYear(month)
+ def withYear(year: Int) = underlying.withYear(year)
+ def withCentury(century: Int) = underlying.withCenturyOfEra(century)
+ def withEra(era: Int) = underlying.withEra(era)
+}
View
40 src/main/scala/org/scala_tools/time/RichLocalDateTimeProperty.scala
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import java.util.Locale
+import org.joda.time._
+
+class RichLocalDateTimeProperty(underlying: LocalDateTime.Property) {
+ def localDateTime: LocalDateTime =
+ underlying.getLocalDateTime
+ def roundFloor: LocalDateTime =
+ underlying.roundFloorCopy
+ def roundCeiling: LocalDateTime =
+ underlying.roundCeilingCopy
+ def roundDown: LocalDateTime =
+ underlying.roundFloorCopy
+ def roundUp: LocalDateTime =
+ underlying.roundCeilingCopy
+ def round: LocalDateTime =
+ underlying.roundHalfEvenCopy
+
+ def apply(value: Int): LocalDateTime = underlying.setCopy(value)
+ def apply(text: String): LocalDateTime = underlying.setCopy(text)
+ def apply(text: String, locale: Locale): LocalDateTime =
+ underlying.setCopy(text, locale)
+}
View
40 src/main/scala/org/scala_tools/time/RichLocalTimeProperty.scala
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import java.util.Locale
+import org.joda.time._
+
+class RichLocalTimeProperty(underlying: LocalTime.Property) {
+ def localTime: LocalTime =
+ underlying.getLocalTime
+ def roundFloor: LocalTime =
+ underlying.roundFloorCopy
+ def roundCeiling: LocalTime =
+ underlying.roundCeilingCopy
+ def roundDown: LocalTime =
+ underlying.roundFloorCopy
+ def roundUp: LocalTime =
+ underlying.roundCeilingCopy
+ def round: LocalTime =
+ underlying.roundHalfEvenCopy
+
+ def apply(value: Int): LocalTime = underlying.setCopy(value)
+ def apply(text: String): LocalTime = underlying.setCopy(text)
+ def apply(text: String, locale: Locale): LocalTime =
+ underlying.setCopy(text, locale)
+}
View
32 src/main/scala/org/scala_tools/time/RichPartial.scala
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import org.joda.time._
+
+class RichPartial(underlying: Partial) {
+ def formatter = underlying.getFormatter
+
+ def -(period: ReadablePeriod): Partial =
+ underlying.minus(period)
+ def -(builder: DurationBuilder): Partial =
+ underlying.minus(builder.underlying)
+ def +(period: ReadablePeriod): Partial =
+ underlying.plus(period)
+ def +(builder: DurationBuilder): Partial =
+ underlying.plus(builder.underlying)
+}
View
30 src/main/scala/org/scala_tools/time/RichPartialProperty.scala
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import java.util.Locale
+import org.joda.time._
+
+class RichPartialProperty(underlying: Partial.Property) {
+ def partial: Partial =
+ underlying.getPartial
+
+ def apply(value: Int): Partial = underlying.setCopy(value)
+ def apply(text: String): Partial = underlying.setCopy(text)
+ def apply(text: String, locale: Locale): Partial =
+ underlying.setCopy(text, locale)
+}
View
4 src/main/scala/org/scala_tools/time/RichReadableDuration.scala
@@ -18,9 +18,9 @@ package org.scala_tools.time
import org.joda.time._
-class RichReadableDuration[T <: ReadableDuration](underlying: T) extends Ordered[T] {
+class RichReadableDuration(underlying: ReadableDuration) extends Ordered[ReadableDuration] {
def millis: Long =
underlying.getMillis
- def compare(other: T): Int =
+ def compare(other: ReadableDuration): Int =
underlying.compareTo(other)
}
View
4 src/main/scala/org/scala_tools/time/RichReadableInstant.scala
@@ -18,14 +18,14 @@ package org.scala_tools.time
import org.joda.time._
-class RichReadableInstant[T <: ReadableInstant](underlying: T) extends Ordered[T] {
+class RichReadableInstant(underlying: ReadableInstant) extends Ordered[ReadableInstant] {
def chronology: Chronology =
underlying.getChronology
def millis: Long =
underlying.getMillis
def zone: DateTimeZone =
underlying.getZone
- override def compare(that: T): Int =
+ override def compare(that: ReadableInstant): Int =
underlying.compareTo(that)
def to(other: ReadableInstant): Interval =
View
23 src/main/scala/org/scala_tools/time/RichReadablePartial.scala
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import org.joda.time._
+
+class RichReadablePartial(underlying: ReadablePartial) {
+ def chronology = underlying.getChronology
+}
View
2 src/main/scala/org/scala_tools/time/StaticDateTime.scala
@@ -22,6 +22,8 @@ import org.scala_tools.time.Implicits._
object StaticDateTime extends StaticDateTime
trait StaticDateTime {
+ type Property = DateTime.Property
+
def now = new DateTime
def nextSecond = now + 1.second
View
19 src/main/scala/org/scala_tools/time/StaticLocalDate.scala
@@ -1,4 +1,5 @@
/**
+ * Copyright 2009 Jorge Ortiz
* Copyright 2009 Barry Kaplan
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,20 +17,32 @@
**/
package org.scala_tools.time
+import java.util.{Calendar, Date}
import org.joda.time._
import org.scala_tools.time.Implicits._
object StaticLocalDate extends StaticLocalDate
trait StaticLocalDate {
+ type Property = LocalDate.Property
+
+ def fromCalendarFields(calendar: Calendar) =
+ LocalDate.fromCalendarFields(calendar)
+ def fromDateFields(date: Date) =
+ LocalDate.fromDateFields(date)
+
def now = new LocalDate
+ def today = new LocalDate
- def nextSecond = now + 1.second
- def nextMinute = now + 1.minute
- def nextHour = now + 1.hour
def nextDay = now + 1.day
def tomorrow = now + 1.day
def nextWeek = now + 1.week
def nextMonth = now + 1.month
def nextYear = now + 1.year
+
+ def lastDay = now - 1.day
+ def yesterday = now - 1.day
+ def lastWeek = now - 1.week
+ def lastMonth = now - 1.month
+ def lastYear = now - 1.year
}
View
52 src/main/scala/org/scala_tools/time/StaticLocalDateTime.scala
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import java.util.{Calendar, Date}
+import org.joda.time._
+import org.scala_tools.time.Implicits._
+
+object StaticLocalDateTime extends StaticLocalDateTime
+
+trait StaticLocalDateTime {
+ type Property = LocalDateTime.Property
+
+ def fromCalendarFields(calendar: Calendar) =
+ LocalDateTime.fromCalendarFields(calendar)
+ def fromDateFields(date: Date) =
+ LocalDateTime.fromDateFields(date)
+
+ def now = new LocalDateTime
+
+ def nextSecond = now + 1.second
+ def nextMinute = now + 1.minute
+ def nextHour = now + 1.hour
+ def nextDay = now + 1.day
+ def tomorrow = now + 1.day
+ def nextWeek = now + 1.week
+ def nextMonth = now + 1.month
+ def nextYear = now + 1.year
+
+ def lastSecond = now - 1.second
+ def lastMinute = now - 1.minute
+ def lastHour = now - 1.hour
+ def lastDay = now - 1.day
+ def yesterday = now - 1.day
+ def lastWeek = now - 1.week
+ def lastMonth = now - 1.month
+ def lastYear = now - 1.year
+}
View
25 src/main/scala/org/scala_tools/time/StaticLocalTime.scala
@@ -1,4 +1,5 @@
/**
+ * Copyright 2009 Jorge Ortiz
* Copyright 2009 Barry Kaplan
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,20 +17,34 @@
**/
package org.scala_tools.time
+import java.util.{Calendar, Date}
import org.joda.time._
import org.scala_tools.time.Implicits._
object StaticLocalTime extends StaticLocalTime
trait StaticLocalTime {
+ type Property = LocalTime.Property
+
+ final val MIDNIGHT = LocalTime.MIDNIGHT
+ final val Midnight = LocalTime.MIDNIGHT
+
+ def fromCalendarFields(calendar: Calendar) =
+ LocalTime.fromCalendarFields(calendar)
+ def fromDateFields(date: Date) =
+ LocalTime.fromDateFields(date)
+ def fromMillisOfDay(millis: Long) =
+ LocalTime.fromMillisOfDay(millis)
+ def fromMillisOfDay(millis: Long, chrono: Chronology) =
+ LocalTime.fromMillisOfDay(millis, chrono)
+
def now = new LocalTime
+ def nextSecond = now + 1.second
+ def nextMinute = now + 1.minute
+ def nextHour = now + 1.hour
+
def lastSecond = now - 1.second
def lastMinute = now - 1.minute
def lastHour = now - 1.hour
- def lastDay = now - 1.day
- def yesterday = now - 1.day
- def lastWeek = now - 1.week
- def lastMonth = now - 1.month
- def lastYear = now - 1.year
}
View
25 src/main/scala/org/scala_tools/time/StaticPartial.scala
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2009 Jorge Ortiz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.scala_tools.time
+
+import org.joda.time._
+
+object StaticPartial extends StaticPartial
+
+trait StaticPartial {
+ type Property = Partial.Property
+}

0 comments on commit 04d9483

Please sign in to comment.
Something went wrong with that request. Please try again.