├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README
├── ReleaseChecklist.txt
├── build.sbt
├── notes
├── 0.3.markdown
├── 0.4.markdown
├── 0.5.markdown
└── about.markdown
├── project
└── build.sbt
└── src
├── changes
└── changes.xml
├── main
└── scala
│ └── org
│ └── scala_tools
│ └── time
│ ├── DurationBuilder.scala
│ ├── Implicits.scala
│ ├── Imports.scala
│ ├── RichAbstractDateTime.scala
│ ├── RichAbstractInstant.scala
│ ├── RichAbstractPartial.scala
│ ├── RichAbstractReadableInstantFieldProperty.scala
│ ├── RichChronology.scala
│ ├── RichDate.scala
│ ├── RichDateMidnight.scala
│ ├── RichDateTime.scala
│ ├── RichDateTimeFormatter.scala
│ ├── RichDateTimeProperty.scala
│ ├── RichDateTimeZone.scala
│ ├── RichDuration.scala
│ ├── RichInstant.scala
│ ├── RichInt.scala
│ ├── RichLocalDate.scala
│ ├── RichLocalDateProperty.scala
│ ├── RichLocalDateTime.scala
│ ├── RichLocalDateTimeProperty.scala
│ ├── RichLocalTime.scala
│ ├── RichLocalTimeProperty.scala
│ ├── RichLong.scala
│ ├── RichPartial.scala
│ ├── RichPartialProperty.scala
│ ├── RichPeriod.scala
│ ├── RichReadableDateTime.scala
│ ├── RichReadableDuration.scala
│ ├── RichReadableInstant.scala
│ ├── RichReadableInterval.scala
│ ├── RichReadablePartial.scala
│ ├── RichReadablePeriod.scala
│ ├── StaticDateTime.scala
│ ├── StaticDateTimeFormat.scala
│ ├── StaticDateTimeZone.scala
│ ├── StaticDuration.scala
│ ├── StaticInterval.scala
│ ├── StaticLocalDate.scala
│ ├── StaticLocalDateTime.scala
│ ├── StaticLocalTime.scala
│ ├── StaticPartial.scala
│ └── StaticPeriod.scala
└── test
└── scala
└── org
└── scala_tools
└── time
├── AppTest.scala
└── MySpec.scala
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | target/
3 | lib_managed/
4 | boot/
5 | src_managed/
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Release Notes
2 |
3 | # 0.7
4 |
5 | - drop support for Scala 2.8.x
6 | - cross-compile against Scala 2.10
7 | - upgrade to joda-time 2.2
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | A Scala wrapper for Joda Time
2 |
3 | USAGE:
4 |
5 | import org.scala_tools.time.Imports._
6 |
7 | DateTime.now
8 | // returns org.joda.time.DateTime = 2009-04-27T13:25:42.659-07:00
9 |
10 | DateTime.now.hour(2).minute(45).second(10)
11 | // returns org.joda.time.DateTime = 2009-04-27T02:45:10.313-07:00
12 |
13 | DateTime.now + 2.months
14 | // returns org.joda.time.DateTime = 2009-06-27T13:25:59.195-07:00
15 |
16 | DateTime.nextMonth < DateTime.now + 2.months
17 | // returns Boolean = true
18 |
19 | DateTime.now to DateTime.tomorrow
20 | // return org.joda.time.Interval =
21 | // 2009-04-27T13:47:14.840/2009-04-28T13:47:14.840
22 |
23 | (DateTime.now to DateTime.nextSecond).millis
24 | // returns Long = 1000
25 |
26 | 2.hours + 45.minutes + 10.seconds
27 | // returns org.scala_tools.time.DurationBuilder
28 | // (can be used as a Duration or as a Period)
29 |
30 | (2.hours + 45.minutes + 10.seconds).millis
31 | // returns Long = 9910000
32 |
33 | 2.months + 3.days
34 | // returns Period
35 |
36 | This is mostly a convenience wrapper around the Joda Time libraries, adding
37 | more pleasant syntax like operators for addition, subtraction, and comparison.
38 | Also, most fields usually available as "getField" are now simply available as
39 | "field", following the Scala convention. Some instances of "asX" or "toX" have
40 | also been shortened.
41 |
42 | Please see Joda Time for full explanation of key concepts and API:
43 | http://joda-time.sourceforge.net/index.html
44 |
45 | INSTALLATION:
46 |
47 | Add the following to your sbt build:
48 |
49 | libraryDependencies += "org.scalaj" %% "scalaj-time" % "0.7"
50 |
51 | MOTIVATION:
52 |
53 | The Java Date and Calendar libraries are largely inadequate. They are mutable,
54 | not thread-safe, and very inconvenient to use.
55 |
56 | The Joda Time library is a great replacement for Java's Date and Calendar
57 | classes. They're immutable by default, have a much richer and nicer API, and
58 | can easily be converted to Java's Date and Calendar classes when necessary.
59 |
60 | This project provides a thin layer of convenience around the Joda Time
61 | libraries, making them more idiomatic to use within Scala.
--------------------------------------------------------------------------------
/ReleaseChecklist.txt:
--------------------------------------------------------------------------------
1 | Pre-release checklist:
2 |
3 | [ ] Update CHANGELOG.md with features included in the new release
4 | [ ] Update sbt example in README.md with latest version number
5 | [ ] Remove the "-SNAPSHOT" from the version in build.sbt
6 | [ ] Reload sbt
7 | [ ] Run "; +clean; +test" in sbt to make sure everything works.
8 | [ ] Run "+publish-local"
9 | [ ] Commit these changes (but don't push!)
10 |
11 | Release checklist:
12 |
13 | [ ] Run "+publish" in sbt
14 | [ ] Find the scala-time repository on oss.sonatype.org / Staging Repositories
15 | [ ] Select it and click Close
16 | [ ] Select it and click Release
17 |
18 | Post-release checklist:
19 |
20 | [ ] Tag the release version (e.g., "git tag v1.0.0")
21 | [ ] Bump the version in build.sbt and add "-SNAPSHOT" to it
22 | [ ] Commit these changes
23 | [ ] Push both commits to Github
24 | [ ] Push tags to Github with "git push origin --tags"
25 |
--------------------------------------------------------------------------------
/build.sbt:
--------------------------------------------------------------------------------
1 | organization := "org.scalaj"
2 |
3 | name := "scalaj-time"
4 |
5 | version := "0.8-SNAPSHOT"
6 |
7 | publishMavenStyle := true
8 |
9 | crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2", "2.10.2")
10 |
11 | crossVersion := CrossVersion.full
12 |
13 | scalacOptions <++= scalaVersion map { v =>
14 | if (v.startsWith("2.10"))
15 | Seq("-unchecked", "-deprecation", "-feature", "-language:implicitConversions")
16 | else
17 | Seq("-unchecked", "-deprecation")
18 | }
19 |
20 | libraryDependencies ++= Seq(
21 | "joda-time" % "joda-time" % "2.2",
22 | "org.joda" % "joda-convert" % "1.2" % "compile"
23 | )
24 |
25 | pomExtra := (
26 | https://github.com/jorgeortiz85/scala-time
27 |
28 |
29 | Apache
30 | http://www.opensource.org/licenses/Apache-2.0
31 | repo
32 |
33 |
34 |
35 | git@github.com:jorgeortiz85/scala-time.git
36 | scm:git:git@github.com:jorgeortiz85/scala-time.git
37 |
38 |
39 |
40 | jorgeortiz85
41 | Jorge Ortiz
42 | https://github.com/jorgeortiz85
43 |
44 |
45 | )
46 |
47 | publishTo <<= version { v =>
48 | val nexus = "http://oss.sonatype.org/"
49 | if (v.endsWith("-SNAPSHOT"))
50 | Some("snapshots" at nexus+"content/repositories/snapshots")
51 | else
52 | Some("releases" at nexus+"service/local/staging/deploy/maven2")
53 | }
54 |
55 | credentials ++= {
56 | val sonatype = ("Sonatype Nexus Repository Manager", "oss.sonatype.org")
57 | def loadMavenCredentials(file: java.io.File) : Seq[Credentials] = {
58 | xml.XML.loadFile(file) \ "servers" \ "server" map (s => {
59 | val host = (s \ "id").text
60 | val realm = if (host == sonatype._2) sonatype._1 else "Unknown"
61 | Credentials(realm, host, (s \ "username").text, (s \ "password").text)
62 | })
63 | }
64 | val ivyCredentials = Path.userHome / ".ivy2" / ".credentials"
65 | val mavenCredentials = Path.userHome / ".m2" / "settings.xml"
66 | (ivyCredentials.asFile, mavenCredentials.asFile) match {
67 | case (ivy, _) if ivy.canRead => Credentials(ivy) :: Nil
68 | case (_, mvn) if mvn.canRead => loadMavenCredentials(mvn)
69 | case _ => Nil
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/notes/0.3.markdown:
--------------------------------------------------------------------------------
1 | No bug fixes or features in this release. Now compiles against 2.8.1 as well as 2.8.0.
--------------------------------------------------------------------------------
/notes/0.4.markdown:
--------------------------------------------------------------------------------
1 | 0.4 release:
2 |
3 | * Upgrade to Joda-Time 1.6.2
4 | * Binary compatibility with Scala 2.9.0 and 2.9.0-1
5 |
--------------------------------------------------------------------------------
/notes/0.5.markdown:
--------------------------------------------------------------------------------
1 | 0.5 release:
2 |
3 | * Adds toLocalDateTime, toLocalDate, and toLocalTime implicits to java.util.Date (thanks to Alexander Azarov!)
4 | * Cross compiled against Scala 2.9.1
5 |
--------------------------------------------------------------------------------
/notes/about.markdown:
--------------------------------------------------------------------------------
1 | scala-time is a convenient and lightweight Scala wrapper for the Joda Time libraries.
--------------------------------------------------------------------------------
/project/build.sbt:
--------------------------------------------------------------------------------
1 | addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")
2 |
--------------------------------------------------------------------------------
/src/changes/changes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Changes for scala-time
4 |
5 |
6 |
7 |
18 |
19 | Support for all subclasses of ReadablePartial and their Properties
20 | Support for LocalDate and LocalTime, including static forwarders
21 | Explicit return types for all implicits
22 | Shorter methods for DateTimeFormatter, and a new parseOption method
23 | "apply" method is now an alias for setCopy in DateTime.Property
24 | Shortened with* (withHour, withMinute, etc) updaters to DateTime
25 | Static forwarder for DateTimeFormat in default Imports
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/DurationBuilder.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | private[time] object DurationBuilder {
22 | def apply(underlying: Period): DurationBuilder =
23 | new DurationBuilder(underlying)
24 | }
25 |
26 | // Duration Builder
27 | sealed private[time] class DurationBuilder(val underlying: Period) {
28 | // DurationBuilder + DurationBuilder = DurationBuilder
29 | // This is the only operation that can maintain a DurationBuilder
30 | // Everything else kicks us out to DateTime, Duration, or Period
31 | def +(that: DurationBuilder): DurationBuilder =
32 | DurationBuilder(this.underlying.plus(that.underlying))
33 |
34 | def ago: DateTime =
35 | StaticDateTime.now.minus(underlying)
36 | def later: DateTime =
37 | StaticDateTime.now.plus(underlying)
38 | def from(dt: DateTime): DateTime =
39 | dt.plus(underlying)
40 | def before(dt: DateTime): DateTime =
41 | dt.minus(underlying)
42 |
43 | def standardDuration: Duration =
44 | underlying.toStandardDuration
45 | def toDuration: Duration =
46 | underlying.toStandardDuration
47 | def toPeriod: Period =
48 | underlying
49 |
50 | def -(period: ReadablePeriod): Period =
51 | underlying.minus(period)
52 | def +(period: ReadablePeriod): Period =
53 | underlying.plus(period)
54 |
55 | def millis: Long =
56 | underlying.toStandardDuration.getMillis
57 | def seconds: Long =
58 | underlying.toStandardDuration.getStandardSeconds
59 | def -(amount: Long): Duration =
60 | underlying.toStandardDuration.minus(amount)
61 | def -(amount: ReadableDuration): Duration =
62 | underlying.toStandardDuration.minus(amount)
63 | def +(amount: Long): Duration =
64 | underlying.toStandardDuration.plus(amount)
65 | def +(amount: ReadableDuration): Duration =
66 | underlying.toStandardDuration.plus(amount)
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/Implicits.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | * Copyright 2009 Barry Kaplan
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | **/
18 | package org.scala_tools.time
19 |
20 | import java.util.{Date, Locale}
21 | import org.joda.time._
22 | import org.joda.time.base.{AbstractDateTime, AbstractInstant, AbstractPartial}
23 | import org.joda.time.format.DateTimeFormatter
24 | import org.joda.time.field.AbstractReadableInstantFieldProperty
25 |
26 | object Implicits extends Implicits
27 | object BuilderImplicits extends Implicits
28 | object IntImplicits extends IntImplicits
29 | object JodaImplicits extends JodaImplicits
30 |
31 | trait Implicits extends BuilderImplicits with IntImplicits with DateImplicits with JodaImplicits
32 |
33 | trait BuilderImplicits {
34 | implicit def forcePeriod(builder: DurationBuilder): Period =
35 | builder.underlying
36 | implicit def forceDuration(builder: DurationBuilder): Duration =
37 | builder.underlying.toStandardDuration
38 | }
39 |
40 | trait IntImplicits {
41 | implicit def RichInt(n: Int): RichInt = new org.scala_tools.time.RichInt(n)
42 | implicit def RichLong(n: Long): RichLong = new org.scala_tools.time.RichLong(n)
43 | }
44 |
45 | trait DateImplicits {
46 | implicit def RichDate(d: Date): RichDate = new org.scala_tools.time.RichDate(d)
47 | }
48 |
49 | trait JodaImplicits {
50 | implicit def RichAbstractDateTime(dt: AbstractDateTime): RichAbstractDateTime = new RichAbstractDateTime(dt)
51 | implicit def RichAbstractInstant(in: AbstractInstant): RichAbstractInstant = new RichAbstractInstant(in)
52 | implicit def RichAbstractPartial(pt: AbstractPartial): RichAbstractPartial = new RichAbstractPartial(pt)
53 | implicit def RichAbstractReadableInstantFieldProperty(pty: AbstractReadableInstantFieldProperty): RichAbstractReadableInstantFieldProperty =
54 | new RichAbstractReadableInstantFieldProperty(pty)
55 | implicit def RichChronology(ch: Chronology): RichChronology = new RichChronology(ch)
56 | implicit def RichDateMidnight(dm: DateMidnight): RichDateMidnight = new RichDateMidnight(dm)
57 | implicit def RichDateTime(dt: DateTime): RichDateTime = new RichDateTime(dt)
58 | implicit def RichDateTimeFormatter(fmt: DateTimeFormatter): RichDateTimeFormatter = new RichDateTimeFormatter(fmt)
59 | implicit def RichDateTimeProperty(pty: DateTime.Property): RichDateTimeProperty = new RichDateTimeProperty(pty)
60 | implicit def RichDateTimeZone(zone: DateTimeZone): RichDateTimeZone = new RichDateTimeZone(zone)
61 | implicit def RichDuration(dur: Duration): RichDuration = new RichDuration(dur)
62 | implicit def RichInstant(in: Instant): RichInstant = new RichInstant(in)
63 | implicit def RichLocalDate(ld: LocalDate): RichLocalDate = new RichLocalDate(ld)
64 | implicit def RichLocalDateProperty(pty: LocalDate.Property): RichLocalDateProperty = new RichLocalDateProperty(pty)
65 | implicit def RichLocalDateTime(dt: LocalDateTime): RichLocalDateTime = new RichLocalDateTime(dt)
66 | implicit def RichLocalDateTimeProperty(pty: LocalDateTime.Property): RichLocalDateTimeProperty = new RichLocalDateTimeProperty(pty)
67 | implicit def RichLocalTime(lt: LocalTime): RichLocalTime = new RichLocalTime(lt)
68 | implicit def RichLocalTimeProperty(pty: LocalTime.Property): RichLocalTimeProperty = new RichLocalTimeProperty(pty)
69 | implicit def RichPartial(pt: Partial): RichPartial = new RichPartial(pt)
70 | implicit def RichPartialProperty(pty: Partial.Property): RichPartialProperty = new RichPartialProperty(pty)
71 | implicit def RichPeriod(per: Period): RichPeriod = new RichPeriod(per)
72 | implicit def RichReadableDateTime(dt: ReadableDateTime): RichReadableDateTime = new RichReadableDateTime(dt)
73 | implicit def RichReadableDuration(dur: ReadableDuration): RichReadableDuration = new RichReadableDuration(dur)
74 | implicit def RichReadableInstant(in: ReadableInstant): RichReadableInstant = new RichReadableInstant(in)
75 | implicit def RichReadableInterval(in: ReadableInterval): RichReadableInterval = new RichReadableInterval(in)
76 | implicit def RichReadablePartial(rp: ReadablePartial): RichReadablePartial = new RichReadablePartial(rp)
77 | implicit def RichReadablePeriod(per: ReadablePeriod): RichReadablePeriod = new RichReadablePeriod(per)
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/Imports.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | * Copyright 2009 Barry Kaplan
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | **/
18 | package org.scala_tools.time
19 |
20 | object Imports extends Imports
21 | object TypeImports extends TypeImports
22 | object StaticForwarderImports extends StaticForwarderImports
23 |
24 | trait Imports extends TypeImports with StaticForwarderImports with Implicits
25 |
26 | trait TypeImports {
27 | type Chronology = org.joda.time.Chronology
28 | type DateTime = org.joda.time.DateTime
29 | type DateTimeFormat = org.joda.time.format.DateTimeFormat
30 | type DateTimeZone = org.joda.time.DateTimeZone
31 | type Duration = org.joda.time.Duration
32 | type Interval = org.joda.time.Interval
33 | type LocalDate = org.joda.time.LocalDate
34 | type LocalDateTime = org.joda.time.LocalDateTime
35 | type LocalTime = org.joda.time.LocalTime
36 | type Period = org.joda.time.Period
37 | type Partial = org.joda.time.Partial
38 | }
39 |
40 | trait StaticForwarderImports {
41 | val DateTime = org.scala_tools.time.StaticDateTime
42 | val DateTimeFormat = org.scala_tools.time.StaticDateTimeFormat
43 | val DateTimeZone = org.scala_tools.time.StaticDateTimeZone
44 | val Duration = org.scala_tools.time.StaticDuration
45 | val Interval = org.scala_tools.time.StaticInterval
46 | val LocalDate = org.scala_tools.time.StaticLocalDate
47 | val LocalDateTime = org.scala_tools.time.StaticLocalDateTime
48 | val LocalTime = org.scala_tools.time.StaticLocalTime
49 | val Period = org.scala_tools.time.StaticPeriod
50 | val Partial = org.scala_tools.time.StaticPartial
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichAbstractDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.{Locale, Calendar, GregorianCalendar}
20 | import org.joda.time._
21 | import org.joda.time.base.AbstractDateTime
22 |
23 | class RichAbstractDateTime(underlying: AbstractDateTime) {
24 | def calendar(locale: Locale): Calendar =
25 | underlying.toCalendar(locale)
26 | def gregorianCalendar: Calendar =
27 | underlying.toGregorianCalendar
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichAbstractInstant.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Date
20 | import org.joda.time._
21 | import org.joda.time.base.AbstractInstant
22 |
23 | class RichAbstractInstant(underlying: AbstractInstant) {
24 | def date: Date =
25 | underlying.toDate
26 | def dateTime: DateTime =
27 | underlying.toDateTime
28 | def dateTime(chronology: Chronology): DateTime =
29 | underlying.toDateTime(chronology)
30 | def dateTime(zone: DateTimeZone): DateTime =
31 | underlying.toDateTime(zone)
32 | def dateTimeISO: DateTime =
33 | underlying.toDateTimeISO
34 | def instant: Instant =
35 | underlying.toInstant
36 | def mutableDateTime: MutableDateTime =
37 | underlying.toMutableDateTime
38 | def mutableDateTime(chronology: Chronology): MutableDateTime =
39 | underlying.toMutableDateTime(chronology)
40 | def mutableDateTime(zone: DateTimeZone): MutableDateTime =
41 | underlying.toMutableDateTime(zone)
42 | def mutableDateTimeISO: MutableDateTime =
43 | underlying.toMutableDateTimeISO
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichAbstractPartial.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 | import org.joda.time.base.AbstractPartial
21 |
22 | class RichAbstractPartial(underlying: AbstractPartial) extends Ordered[AbstractPartial] {
23 | def fields = underlying.getFields
24 | def fieldTypes = underlying.getFieldTypes
25 | def values = underlying.getValues
26 |
27 | override def compare(that: AbstractPartial): Int =
28 | underlying.compareTo(that)
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichAbstractReadableInstantFieldProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 | import org.joda.time.field.AbstractReadableInstantFieldProperty
22 |
23 | class RichAbstractReadableInstantFieldProperty(underlying: AbstractReadableInstantFieldProperty) {
24 | def shortText: String =
25 | underlying.getAsShortText
26 | def asShortText: String =
27 | underlying.getAsShortText
28 | def shortText(locale: Locale): String =
29 | underlying.getAsShortText(locale)
30 | def asShortText(locale: Locale): String =
31 | underlying.getAsShortText(locale)
32 | def asString: String =
33 | underlying.getAsString
34 | def text: String =
35 | underlying.getAsText
36 | def asText: String =
37 | underlying.getAsText
38 | def text(locale: Locale): String =
39 | underlying.getAsText(locale)
40 | def asText(locale: Locale): String =
41 | underlying.getAsText(locale)
42 | def durationField: DurationField =
43 | underlying.getDurationField
44 | def field: DateTimeField =
45 | underlying.getField
46 | def fieldType: DateTimeFieldType =
47 | underlying.getFieldType
48 | def leapAmount: Int =
49 | underlying.getLeapAmount
50 | def leapDurationField: DurationField =
51 | underlying.getLeapDurationField
52 | def maximumValue: Int =
53 | underlying.getMaximumValue
54 | def maxValue: Int =
55 | underlying.getMaximumValue
56 | def maximumValueOverall: Int =
57 | underlying.getMaximumValueOverall
58 | def maxValueOverall: Int =
59 | underlying.getMaximumValueOverall
60 | def minimumValue: Int =
61 | underlying.getMinimumValue
62 | def minValue: Int =
63 | underlying.getMinimumValue
64 | def minimumValueOverall: Int =
65 | underlying.getMinimumValueOverall
66 | def minValueOverall: Int =
67 | underlying.getMinimumValueOverall
68 | def name: String =
69 | underlying.getName
70 | def rangeDurationField: DurationField =
71 | underlying.getRangeDurationField
72 |
73 | def interval: Interval =
74 | underlying.toInterval
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichChronology.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichChronology(underlying: Chronology) {
22 | def zone: Option[DateTimeZone] =
23 | nullCheck(underlying.getZone)
24 | private def nullCheck[T <: AnyRef](x: T): Option[T] =
25 | if (x == null) None else Some(x)
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDate.scala:
--------------------------------------------------------------------------------
1 | package org.scala_tools.time
2 |
3 | import java.util.Date
4 | import org.joda.time._
5 |
6 | class RichDate(val d: Date) {
7 | def toLocalDateTime: LocalDateTime = StaticLocalDateTime.fromDateFields(d)
8 | def toLocalDate: LocalDate = StaticLocalDate.fromDateFields(d)
9 | def toLocalTime: LocalTime = StaticLocalTime.fromDateFields(d)
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDateMidnight.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichDateMidnight(underlying: DateMidnight) {
22 | def -(duration: Long): DateMidnight =
23 | underlying.minus(duration)
24 | def -(duration: ReadableDuration): DateMidnight =
25 | underlying.minus(duration)
26 | def -(period: ReadablePeriod): DateMidnight =
27 | underlying.minus(period)
28 | def -(builder: DurationBuilder): DateMidnight =
29 | underlying.minus(builder.underlying)
30 | def +(duration: Long): DateMidnight =
31 | underlying.plus(duration)
32 | def +(duration: ReadableDuration): DateMidnight =
33 | underlying.plus(duration)
34 | def +(period: ReadablePeriod): DateMidnight =
35 | underlying.plus(period)
36 | def +(builder: DurationBuilder): DateMidnight =
37 | underlying.plus(builder.underlying)
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichDateTime(underlying: DateTime) {
22 | def -(duration: Long): DateTime =
23 | underlying.minus(duration)
24 | def -(duration: ReadableDuration): DateTime =
25 | underlying.minus(duration)
26 | def -(period: ReadablePeriod): DateTime =
27 | underlying.minus(period)
28 | def -(builder: DurationBuilder): DateTime =
29 | underlying.minus(builder.underlying)
30 | def +(duration: Long): DateTime =
31 | underlying.plus(duration)
32 | def +(duration: ReadableDuration): DateTime =
33 | underlying.plus(duration)
34 | def +(period: ReadablePeriod): DateTime =
35 | underlying.plus(period)
36 | def +(builder: DurationBuilder): DateTime =
37 | underlying.plus(builder.underlying)
38 |
39 | def second: DateTime.Property = underlying.secondOfMinute
40 | def minute: DateTime.Property = underlying.minuteOfHour
41 | def hour: DateTime.Property = underlying.hourOfDay
42 | def day: DateTime.Property = underlying.dayOfMonth
43 | def week: DateTime.Property = underlying.weekOfWeekyear
44 | def month: DateTime.Property = underlying.monthOfYear
45 | def year: DateTime.Property = underlying.year
46 | def century: DateTime.Property = underlying.centuryOfEra
47 | def era: DateTime.Property = underlying.era
48 |
49 | def withSecond(second: Int) = underlying.withSecondOfMinute(second)
50 | def withMinute(minute: Int) = underlying.withMinuteOfHour(minute)
51 | def withHour(hour: Int) = underlying.withHourOfDay(hour)
52 | def withDay(day: Int) = underlying.withDayOfMonth(day)
53 | def withWeek(week: Int) = underlying.withWeekOfWeekyear(week)
54 | def withMonth(month: Int) = underlying.withMonthOfYear(month)
55 | def withYear(year: Int) = underlying.withYear(year)
56 | def withCentury(century: Int) = underlying.withCenturyOfEra(century)
57 | def withEra(era: Int) = underlying.withEra(era)
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDateTimeFormatter.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 | import org.joda.time.format.{DateTimeFormatter, DateTimeParser,
22 | DateTimePrinter}
23 |
24 | class RichDateTimeFormatter(underlying: DateTimeFormatter) {
25 | def chronology: Chronology = underlying.getChronology
26 | def locale: Locale = underlying.getLocale
27 | def parser: DateTimeParser = underlying.getParser
28 | def pivotYear: Int = underlying.getPivotYear.intValue
29 | def printer: DateTimePrinter = underlying.getPrinter
30 | def zone: DateTimeZone = underlying.getZone
31 | def parseOption(text: String): Option[DateTime] =
32 | try {
33 | Some(underlying.parseDateTime(text))
34 | } catch {
35 | case _ : UnsupportedOperationException => None
36 | case _ : IllegalArgumentException => None
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDateTimeProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 |
22 | class RichDateTimeProperty(underlying: DateTime.Property) {
23 | def dateTime: DateTime =
24 | underlying.getDateTime
25 | def roundFloor: DateTime =
26 | underlying.roundFloorCopy
27 | def roundCeiling: DateTime =
28 | underlying.roundCeilingCopy
29 | def roundDown: DateTime =
30 | underlying.roundFloorCopy
31 | def roundUp: DateTime =
32 | underlying.roundCeilingCopy
33 | def round: DateTime =
34 | underlying.roundHalfEvenCopy
35 |
36 | def apply(value: Int): DateTime = underlying.setCopy(value)
37 | def apply(text: String): DateTime = underlying.setCopy(text)
38 | def apply(text: String, locale: Locale): DateTime =
39 | underlying.setCopy(text, locale)
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDateTimeZone.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichDateTimeZone(underlying: DateTimeZone) {
22 | def id: String =
23 | underlying.getID
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichDuration.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichDuration(underlying: Duration) {
22 | def seconds: Long =
23 | underlying.getStandardSeconds
24 | def -(amount: Long): Duration =
25 | underlying.minus(amount)
26 | def -(amount: ReadableDuration): Duration =
27 | underlying.minus(amount)
28 | def +(amount: Long): Duration =
29 | underlying.plus(amount)
30 | def +(amount: ReadableDuration): Duration =
31 | underlying.plus(amount)
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichInstant.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichInstant(underlying: Instant) {
22 | def -(duration: Long): Instant =
23 | underlying.minus(duration)
24 | def -(duration: ReadableDuration): Instant =
25 | underlying.minus(duration)
26 | def +(duration: Long): Instant =
27 | underlying.plus(duration)
28 | def +(duration: ReadableDuration): Instant =
29 | underlying.plus(duration)
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichInt.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichInt(n: Int) {
22 | // These units of time can build durations or periods.
23 | // At most we lose a leap second. (Unless someone adopts
24 | // leap minutes).
25 | def millis = DurationBuilder(Period.millis(n))
26 | def seconds = DurationBuilder(Period.seconds(n))
27 | def minutes = DurationBuilder(Period.minutes(n))
28 | def hours = DurationBuilder(Period.hours(n))
29 |
30 | // These units of time can only be periods. At this
31 | // point if we made durations automatically we'd start
32 | // getting into trouble with daylight savings time,
33 | // monthly differences, leap years, etc.
34 | def days = Period.days(n)
35 | def weeks = Period.weeks(n)
36 | def months = Period.months(n)
37 | def years = Period.years(n)
38 |
39 | // See above.
40 | def milli = DurationBuilder(Period.millis(n))
41 | def second = DurationBuilder(Period.seconds(n))
42 | def minute = DurationBuilder(Period.minutes(n))
43 | def hour = DurationBuilder(Period.hours(n))
44 |
45 | // See above.
46 | def day = Period.days(n)
47 | def week = Period.weeks(n)
48 | def month = Period.months(n)
49 | def year = Period.years(n)
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalDate.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | * Copyright 2009 Barry Kaplan
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | **/
18 | package org.scala_tools.time
19 |
20 | import org.joda.time._
21 |
22 | class RichLocalDate(underlying: LocalDate) {
23 | def -(period: ReadablePeriod): LocalDate =
24 | underlying.minus(period)
25 | def -(builder: DurationBuilder): LocalDate =
26 | underlying.minus(builder.underlying)
27 | def +(period: ReadablePeriod): LocalDate =
28 | underlying.plus(period)
29 | def +(builder: DurationBuilder): LocalDate =
30 | underlying.plus(builder.underlying)
31 |
32 | def day: LocalDate.Property = underlying.dayOfMonth
33 | def week: LocalDate.Property = underlying.weekOfWeekyear
34 | def month: LocalDate.Property = underlying.monthOfYear
35 | def year: LocalDate.Property = underlying.year
36 | def century: LocalDate.Property = underlying.centuryOfEra
37 | def era: LocalDate.Property = underlying.era
38 |
39 | def withDay(day: Int) = underlying.withDayOfMonth(day)
40 | def withWeek(week: Int) = underlying.withWeekOfWeekyear(week)
41 | def withMonth(month: Int) = underlying.withMonthOfYear(month)
42 | def withYear(year: Int) = underlying.withYear(year)
43 | def withCentury(century: Int) = underlying.withCenturyOfEra(century)
44 | def withEra(era: Int) = underlying.withEra(era)
45 |
46 | def interval = underlying.toInterval
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalDateProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 |
22 | class RichLocalDateProperty(underlying: LocalDate.Property) {
23 | def localDate: LocalDate =
24 | underlying.getLocalDate
25 | def roundFloor: LocalDate =
26 | underlying.roundFloorCopy
27 | def roundCeiling: LocalDate =
28 | underlying.roundCeilingCopy
29 | def roundDown: LocalDate =
30 | underlying.roundFloorCopy
31 | def roundUp: LocalDate =
32 | underlying.roundCeilingCopy
33 | def round: LocalDate =
34 | underlying.roundHalfEvenCopy
35 |
36 | def apply(value: Int): LocalDate = underlying.setCopy(value)
37 | def apply(text: String): LocalDate = underlying.setCopy(text)
38 | def apply(text: String, locale: Locale): LocalDate =
39 | underlying.setCopy(text, locale)
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichLocalDateTime(underlying: LocalDateTime) {
22 | def -(duration: ReadableDuration): LocalDateTime =
23 | underlying.minus(duration)
24 | def -(period: ReadablePeriod): LocalDateTime =
25 | underlying.minus(period)
26 | def -(builder: DurationBuilder): LocalDateTime =
27 | underlying.minus(builder.underlying)
28 | def +(duration: ReadableDuration): LocalDateTime =
29 | underlying.plus(duration)
30 | def +(period: ReadablePeriod): LocalDateTime =
31 | underlying.plus(period)
32 | def +(builder: DurationBuilder): LocalDateTime =
33 | underlying.plus(builder.underlying)
34 |
35 | def second: LocalDateTime.Property = underlying.secondOfMinute
36 | def minute: LocalDateTime.Property = underlying.minuteOfHour
37 | def hour: LocalDateTime.Property = underlying.hourOfDay
38 | def day: LocalDateTime.Property = underlying.dayOfMonth
39 | def week: LocalDateTime.Property = underlying.weekOfWeekyear
40 | def month: LocalDateTime.Property = underlying.monthOfYear
41 | def year: LocalDateTime.Property = underlying.year
42 | def century: LocalDateTime.Property = underlying.centuryOfEra
43 | def era: LocalDateTime.Property = underlying.era
44 |
45 | def withSecond(second: Int) = underlying.withSecondOfMinute(second)
46 | def withMinute(minute: Int) = underlying.withMinuteOfHour(minute)
47 | def withHour(hour: Int) = underlying.withHourOfDay(hour)
48 | def withDay(day: Int) = underlying.withDayOfMonth(day)
49 | def withWeek(week: Int) = underlying.withWeekOfWeekyear(week)
50 | def withMonth(month: Int) = underlying.withMonthOfYear(month)
51 | def withYear(year: Int) = underlying.withYear(year)
52 | def withCentury(century: Int) = underlying.withCenturyOfEra(century)
53 | def withEra(era: Int) = underlying.withEra(era)
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalDateTimeProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 |
22 | class RichLocalDateTimeProperty(underlying: LocalDateTime.Property) {
23 | def localDateTime: LocalDateTime =
24 | underlying.getLocalDateTime
25 | def roundFloor: LocalDateTime =
26 | underlying.roundFloorCopy
27 | def roundCeiling: LocalDateTime =
28 | underlying.roundCeilingCopy
29 | def roundDown: LocalDateTime =
30 | underlying.roundFloorCopy
31 | def roundUp: LocalDateTime =
32 | underlying.roundCeilingCopy
33 | def round: LocalDateTime =
34 | underlying.roundHalfEvenCopy
35 |
36 | def apply(value: Int): LocalDateTime = underlying.setCopy(value)
37 | def apply(text: String): LocalDateTime = underlying.setCopy(text)
38 | def apply(text: String, locale: Locale): LocalDateTime =
39 | underlying.setCopy(text, locale)
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Barry Kaplan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichLocalTime(underlying: LocalTime) {
22 | def -(period: ReadablePeriod): LocalTime =
23 | underlying.minus(period)
24 | def -(builder: DurationBuilder): LocalTime =
25 | underlying.minus(builder.underlying)
26 | def +(period: ReadablePeriod): LocalTime =
27 | underlying.plus(period)
28 | def +(builder: DurationBuilder): LocalTime =
29 | underlying.plus(builder.underlying)
30 |
31 | def second: LocalTime.Property = underlying.secondOfMinute
32 | def minute: LocalTime.Property = underlying.minuteOfHour
33 | def hour: LocalTime.Property = underlying.hourOfDay
34 |
35 | def withSecond(second: Int) = underlying.withSecondOfMinute(second)
36 | def withMinute(minute: Int) = underlying.withMinuteOfHour(minute)
37 | def withHour(hour: Int) = underlying.withHourOfDay(hour)
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLocalTimeProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 |
22 | class RichLocalTimeProperty(underlying: LocalTime.Property) {
23 | def localTime: LocalTime =
24 | underlying.getLocalTime
25 | def roundFloor: LocalTime =
26 | underlying.roundFloorCopy
27 | def roundCeiling: LocalTime =
28 | underlying.roundCeilingCopy
29 | def roundDown: LocalTime =
30 | underlying.roundFloorCopy
31 | def roundUp: LocalTime =
32 | underlying.roundCeilingCopy
33 | def round: LocalTime =
34 | underlying.roundHalfEvenCopy
35 |
36 | def apply(value: Int): LocalTime = underlying.setCopy(value)
37 | def apply(text: String): LocalTime = underlying.setCopy(text)
38 | def apply(text: String, locale: Locale): LocalTime =
39 | underlying.setCopy(text, locale)
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichLong.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichLong(n: Long) {
22 | def toDateTime = new DateTime(n)
23 | def toDuration = new Duration(n)
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichPartial.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichPartial(underlying: Partial) {
22 | def formatter = underlying.getFormatter
23 |
24 | def -(period: ReadablePeriod): Partial =
25 | underlying.minus(period)
26 | def -(builder: DurationBuilder): Partial =
27 | underlying.minus(builder.underlying)
28 | def +(period: ReadablePeriod): Partial =
29 | underlying.plus(period)
30 | def +(builder: DurationBuilder): Partial =
31 | underlying.plus(builder.underlying)
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichPartialProperty.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 |
22 | class RichPartialProperty(underlying: Partial.Property) {
23 | def partial: Partial =
24 | underlying.getPartial
25 |
26 | def apply(value: Int): Partial = underlying.setCopy(value)
27 | def apply(text: String): Partial = underlying.setCopy(text)
28 | def apply(text: String, locale: Locale): Partial =
29 | underlying.setCopy(text, locale)
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichPeriod.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichPeriod(underlying: Period) {
22 | def days: Int =
23 | underlying.getDays
24 | def hours: Int =
25 | underlying.getHours
26 | def millis: Int =
27 | underlying.getMillis
28 | def minutes: Int =
29 | underlying.getMinutes
30 | def months: Int =
31 | underlying.getMonths
32 | def seconds: Int =
33 | underlying.getSeconds
34 | def weeks: Int =
35 | underlying.getWeeks
36 | def years: Int =
37 | underlying.getYears
38 | def -(period: ReadablePeriod): Period =
39 | underlying.minus(period)
40 | def +(period: ReadablePeriod): Period =
41 | underlying.plus(period)
42 | def ago: DateTime =
43 | StaticDateTime.now.minus(underlying)
44 | def later: DateTime =
45 | StaticDateTime.now.plus(underlying)
46 | def from(dt: DateTime): DateTime =
47 | dt.plus(underlying)
48 | def before(dt: DateTime): DateTime =
49 | dt.minus(underlying)
50 |
51 | def standardDuration: Duration =
52 | underlying.toStandardDuration
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadableDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadableDateTime(underlying: ReadableDateTime) {
22 | def second: Int =
23 | underlying.getSecondOfMinute
24 | def minute: Int =
25 | underlying.getMinuteOfHour
26 | def hour: Int =
27 | underlying.getHourOfDay
28 | def day: Int =
29 | underlying.getDayOfMonth
30 | def week: Int =
31 | underlying.getWeekOfWeekyear
32 | def month: Int =
33 | underlying.getMonthOfYear
34 | def year: Int =
35 | underlying.getYear
36 | def century: Int =
37 | underlying.getCenturyOfEra
38 |
39 | def dateTime: DateTime =
40 | underlying.toDateTime
41 | def mutableDateTime: MutableDateTime =
42 | underlying.toMutableDateTime
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadableDuration.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadableDuration(underlying: ReadableDuration) extends Ordered[ReadableDuration] {
22 | def millis: Long =
23 | underlying.getMillis
24 | def compare(other: ReadableDuration): Int =
25 | underlying.compareTo(other)
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadableInstant.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadableInstant(underlying: ReadableInstant) extends Ordered[ReadableInstant] {
22 | def chronology: Chronology =
23 | underlying.getChronology
24 | def millis: Long =
25 | underlying.getMillis
26 | def zone: DateTimeZone =
27 | underlying.getZone
28 | override def compare(that: ReadableInstant): Int =
29 | underlying.compareTo(that)
30 |
31 | def to(other: ReadableInstant): Interval =
32 | new Interval(underlying, other)
33 |
34 | def instant: Instant =
35 | underlying.toInstant
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadableInterval.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadableInterval(underlying: ReadableInterval) {
22 | def chronology: Chronology =
23 | underlying.getChronology
24 | def end: DateTime =
25 | underlying.getEnd
26 | def start: DateTime =
27 | underlying.getStart
28 |
29 | def duration: Duration =
30 | underlying.toDuration
31 | def millis: Long =
32 | underlying.toDuration.getMillis
33 | // TODO: Should > and > be added as aliases for isAfter and isBefore?
34 | // could be convenient, or just confusing because this isn't Ordered.
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadablePartial.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadablePartial(underlying: ReadablePartial) {
22 | def chronology = underlying.getChronology
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/RichReadablePeriod.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | class RichReadablePeriod(underlying: ReadablePeriod) {
22 | def periodType: PeriodType =
23 | underlying.getPeriodType
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 | import org.scala_tools.time.Implicits._
21 |
22 | object StaticDateTime extends StaticDateTime
23 |
24 | trait StaticDateTime {
25 | type Property = DateTime.Property
26 |
27 | def now = new DateTime
28 |
29 | def nextSecond = now + 1.second
30 | def nextMinute = now + 1.minute
31 | def nextHour = now + 1.hour
32 | def nextDay = now + 1.day
33 | def tomorrow = now + 1.day
34 | def nextWeek = now + 1.week
35 | def nextMonth = now + 1.month
36 | def nextYear = now + 1.year
37 |
38 | def lastSecond = now - 1.second
39 | def lastMinute = now - 1.minute
40 | def lastHour = now - 1.hour
41 | def lastDay = now - 1.day
42 | def yesterday = now - 1.day
43 | def lastWeek = now - 1.week
44 | def lastMonth = now - 1.month
45 | def lastYear = now - 1.year
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticDateTimeFormat.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.Locale
20 | import org.joda.time._
21 | import org.joda.time.format._
22 |
23 | object StaticDateTimeFormat extends StaticDateTimeFormat
24 |
25 | trait StaticDateTimeFormat {
26 | def forPattern(pattern: String): DateTimeFormatter =
27 | DateTimeFormat.forPattern(pattern)
28 | def forStyle(style: String): DateTimeFormatter =
29 | DateTimeFormat.forStyle(style)
30 | def fullDate(): DateTimeFormatter = DateTimeFormat.fullDate()
31 | def fullDateTime(): DateTimeFormatter = DateTimeFormat.fullDateTime()
32 | def fullTime(): DateTimeFormatter = DateTimeFormat.fullTime()
33 | def longDate(): DateTimeFormatter = DateTimeFormat.longDate()
34 | def longDateTime(): DateTimeFormatter = DateTimeFormat.longDateTime()
35 | def longTime(): DateTimeFormatter = DateTimeFormat.longTime()
36 | def mediumDate(): DateTimeFormatter = DateTimeFormat.mediumDate()
37 | def mediumDateTime(): DateTimeFormatter = DateTimeFormat.mediumDateTime()
38 | def mediumTime(): DateTimeFormatter = DateTimeFormat.mediumTime()
39 | def patternForStyle(style: String, locale: Locale): String =
40 | DateTimeFormat.patternForStyle(style, locale)
41 | def shortDate(): DateTimeFormatter = DateTimeFormat.shortDate()
42 | def shortDateTime(): DateTimeFormatter = DateTimeFormat.shortDateTime()
43 | def shortTime(): DateTimeFormatter = DateTimeFormat.shortTime()
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticDateTimeZone.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | object StaticDateTimeZone extends StaticDateTimeZone
22 |
23 | trait StaticDateTimeZone {
24 | lazy val UTC = DateTimeZone.UTC
25 | def forID(id: String) = DateTimeZone.forID(id)
26 | def forOffsetHours(hours: Int) = DateTimeZone.forOffsetHours(hours)
27 | def forOffsetHoursMinutes(hours: Int, minutes: Int) =
28 | DateTimeZone.forOffsetHoursMinutes(hours, minutes)
29 | def forOffsetMillis(millis: Int) = DateTimeZone.forOffsetMillis(millis)
30 | def forTimeZone(zone: java.util.TimeZone) = DateTimeZone.forTimeZone(zone)
31 | def getAvailableIDs() = DateTimeZone.getAvailableIDs()
32 | def getDefault() = DateTimeZone.getDefault()
33 | def getNameProvider() = DateTimeZone.getNameProvider()
34 | def getProvider() = DateTimeZone.getProvider()
35 | def setDefault(zone: DateTimeZone) = DateTimeZone.setDefault(zone)
36 | def setNameProvider(nameProvider: tz.NameProvider) =
37 | DateTimeZone.setNameProvider(nameProvider)
38 | def setProvider(provider: tz.Provider) = DateTimeZone.setProvider(provider)
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticDuration.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | object StaticDuration extends StaticDuration
22 |
23 | trait StaticDuration {
24 | def standardDays(days: Long) = Duration.standardDays(days)
25 | def standardHours(hours: Long) = Duration.standardHours(hours)
26 | def standardMinutes(minutes: Long) = Duration.standardMinutes(minutes)
27 | def standardSeconds(seconds: Long) = Duration.standardSeconds(seconds)
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticInterval.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.scala_tools.time.Implicits._
20 | import org.joda.time._
21 |
22 | object StaticInterval extends StaticInterval
23 |
24 | trait StaticInterval {
25 | def thisSecond = StaticDateTime.now.second.interval
26 | def thisMinute = StaticDateTime.now.minute.interval
27 | def thisHour = StaticDateTime.now.hour.interval
28 | def thisDay = StaticDateTime.now.day.interval
29 | def today = StaticDateTime.now.day.interval
30 | def thisWeek = StaticDateTime.now.week.interval
31 | def thisMonth = StaticDateTime.now.month.interval
32 | def thisYear = StaticDateTime.now.year.interval
33 |
34 | def nextSecond = StaticDateTime.nextSecond.second.interval
35 | def nextMinute = StaticDateTime.nextMinute.minute.interval
36 | def nextHour = StaticDateTime.nextHour.hour.interval
37 | def nextDay = StaticDateTime.nextDay.day.interval
38 | def tomorrow = StaticDateTime.nextDay.day.interval
39 | def nextWeek = StaticDateTime.nextWeek.week.interval
40 | def nextMonth = StaticDateTime.nextMonth.month.interval
41 | def nextYear = StaticDateTime.nextYear.year.interval
42 |
43 | def lastSecond = StaticDateTime.lastSecond.second.interval
44 | def lastMinute = StaticDateTime.lastMinute.minute.interval
45 | def lastHour = StaticDateTime.lastHour.hour.interval
46 | def lastDay = StaticDateTime.lastDay.day.interval
47 | def yesterday = StaticDateTime.lastDay.day.interval
48 | def lastWeek = StaticDateTime.lastWeek.week.interval
49 | def lastMonth = StaticDateTime.lastMonth.month.interval
50 | def lastYear = StaticDateTime.lastYear.year.interval
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticLocalDate.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | * Copyright 2009 Barry Kaplan
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | **/
18 | package org.scala_tools.time
19 |
20 | import java.util.{Calendar, Date}
21 | import org.joda.time._
22 | import org.scala_tools.time.Implicits._
23 |
24 | object StaticLocalDate extends StaticLocalDate
25 |
26 | trait StaticLocalDate {
27 | type Property = LocalDate.Property
28 |
29 | def fromCalendarFields(calendar: Calendar) =
30 | LocalDate.fromCalendarFields(calendar)
31 | def fromDateFields(date: Date) =
32 | LocalDate.fromDateFields(date)
33 |
34 | def now = new LocalDate
35 | def today = new LocalDate
36 |
37 | def nextDay = now + 1.day
38 | def tomorrow = now + 1.day
39 | def nextWeek = now + 1.week
40 | def nextMonth = now + 1.month
41 | def nextYear = now + 1.year
42 |
43 | def lastDay = now - 1.day
44 | def yesterday = now - 1.day
45 | def lastWeek = now - 1.week
46 | def lastMonth = now - 1.month
47 | def lastYear = now - 1.year
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticLocalDateTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import java.util.{Calendar, Date}
20 | import org.joda.time._
21 | import org.scala_tools.time.Implicits._
22 |
23 | object StaticLocalDateTime extends StaticLocalDateTime
24 |
25 | trait StaticLocalDateTime {
26 | type Property = LocalDateTime.Property
27 |
28 | def fromCalendarFields(calendar: Calendar) =
29 | LocalDateTime.fromCalendarFields(calendar)
30 | def fromDateFields(date: Date) =
31 | LocalDateTime.fromDateFields(date)
32 |
33 | def now = new LocalDateTime
34 |
35 | def nextSecond = now + 1.second
36 | def nextMinute = now + 1.minute
37 | def nextHour = now + 1.hour
38 | def nextDay = now + 1.day
39 | def tomorrow = now + 1.day
40 | def nextWeek = now + 1.week
41 | def nextMonth = now + 1.month
42 | def nextYear = now + 1.year
43 |
44 | def lastSecond = now - 1.second
45 | def lastMinute = now - 1.minute
46 | def lastHour = now - 1.hour
47 | def lastDay = now - 1.day
48 | def yesterday = now - 1.day
49 | def lastWeek = now - 1.week
50 | def lastMonth = now - 1.month
51 | def lastYear = now - 1.year
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticLocalTime.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | * Copyright 2009 Barry Kaplan
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | **/
18 | package org.scala_tools.time
19 |
20 | import java.util.{Calendar, Date}
21 | import org.joda.time._
22 | import org.scala_tools.time.Implicits._
23 |
24 | object StaticLocalTime extends StaticLocalTime
25 |
26 | trait StaticLocalTime {
27 | type Property = LocalTime.Property
28 |
29 | final val MIDNIGHT = LocalTime.MIDNIGHT
30 | final val Midnight = LocalTime.MIDNIGHT
31 |
32 | def fromCalendarFields(calendar: Calendar) =
33 | LocalTime.fromCalendarFields(calendar)
34 | def fromDateFields(date: Date) =
35 | LocalTime.fromDateFields(date)
36 | def fromMillisOfDay(millis: Long) =
37 | LocalTime.fromMillisOfDay(millis)
38 | def fromMillisOfDay(millis: Long, chrono: Chronology) =
39 | LocalTime.fromMillisOfDay(millis, chrono)
40 |
41 | def now = new LocalTime
42 |
43 | def nextSecond = now + 1.second
44 | def nextMinute = now + 1.minute
45 | def nextHour = now + 1.hour
46 |
47 | def lastSecond = now - 1.second
48 | def lastMinute = now - 1.minute
49 | def lastHour = now - 1.hour
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticPartial.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | object StaticPartial extends StaticPartial
22 |
23 | trait StaticPartial {
24 | type Property = Partial.Property
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/scala/org/scala_tools/time/StaticPeriod.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009 Jorge Ortiz
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | **/
17 | package org.scala_tools.time
18 |
19 | import org.joda.time._
20 |
21 | object StaticPeriod extends StaticPeriod
22 |
23 | trait StaticPeriod {
24 | def days(days: Int) = Period.days(days)
25 | def fieldDifference(start: ReadablePartial, end: ReadablePartial) =
26 | Period.fieldDifference(start, end)
27 | def hours(hours: Int) = Period.hours(hours)
28 | def millis(millis: Int) = Period.millis(millis)
29 | def minutes(minutes: Int) = Period.minutes(minutes)
30 | def months(months: Int) = Period.months(months)
31 | def seconds(seconds: Int) = Period.seconds(seconds)
32 | def weeks(weeks: Int) = Period.weeks(weeks)
33 | def years(years: Int) = Period.years(years)
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/scala/org/scala_tools/time/AppTest.scala:
--------------------------------------------------------------------------------
1 | // package org.scala_tools.time
2 | //
3 | // import org.junit._
4 | // import Assert._
5 | //
6 | // @Test
7 | // class AppTest {
8 | //
9 | // @Test
10 | // def testOK() = assertTrue(true)
11 | //
12 | // // @Test
13 | // // def testKO() = assertTrue(false)
14 | //
15 | // }
16 | //
17 | //
18 |
--------------------------------------------------------------------------------
/src/test/scala/org/scala_tools/time/MySpec.scala:
--------------------------------------------------------------------------------
1 | // package org.scala_tools.time
2 | //
3 | // import org.specs._
4 | // import org.specs.runner.{ConsoleRunner, JUnit4}
5 | //
6 | // class MySpecTest extends JUnit4(MySpec)
7 | // //class MySpecSuite extends ScalaTestSuite(MySpec)
8 | // object MySpecRunner extends ConsoleRunner(MySpec)
9 | //
10 | // object MySpec extends Specification {
11 | // "This wonderful system" should {
12 | // "save the world" in {
13 | // val list = Nil
14 | // list must beEmpty
15 | // }
16 | // }
17 | // }
18 |
--------------------------------------------------------------------------------