Skip to content

Commit 250ae4d

Browse files
author
exoego
committed
Merge remote-tracking branch 'upstream/master' into lazy-constants
# Conflicts: # core/jvm/src/main/scala/org/threeten/bp/zone/TzdbZoneRulesCompiler.scala # core/shared/src/main/scala/org/threeten/bp/DayOfWeek.scala # core/shared/src/main/scala/org/threeten/bp/Duration.scala # core/shared/src/main/scala/org/threeten/bp/Instant.scala # core/shared/src/main/scala/org/threeten/bp/LocalDate.scala # core/shared/src/main/scala/org/threeten/bp/LocalDateTime.scala # core/shared/src/main/scala/org/threeten/bp/LocalTime.scala # core/shared/src/main/scala/org/threeten/bp/Month.scala # core/shared/src/main/scala/org/threeten/bp/MonthDay.scala # core/shared/src/main/scala/org/threeten/bp/OffsetDateTime.scala # core/shared/src/main/scala/org/threeten/bp/OffsetTime.scala # core/shared/src/main/scala/org/threeten/bp/Period.scala # core/shared/src/main/scala/org/threeten/bp/Year.scala # core/shared/src/main/scala/org/threeten/bp/YearMonth.scala # core/shared/src/main/scala/org/threeten/bp/ZoneOffset.scala # core/shared/src/main/scala/org/threeten/bp/chrono/Chronology.scala # core/shared/src/main/scala/org/threeten/bp/chrono/HijrahDate.scala # core/shared/src/main/scala/org/threeten/bp/chrono/HijrahEra.scala # core/shared/src/main/scala/org/threeten/bp/chrono/IsoEra.scala # core/shared/src/main/scala/org/threeten/bp/chrono/JapaneseChronology.scala # core/shared/src/main/scala/org/threeten/bp/chrono/JapaneseEra.scala # core/shared/src/main/scala/org/threeten/bp/chrono/MinguoChronology.scala # core/shared/src/main/scala/org/threeten/bp/chrono/MinguoEra.scala # core/shared/src/main/scala/org/threeten/bp/chrono/ThaiBuddhistChronology.scala # core/shared/src/main/scala/org/threeten/bp/chrono/ThaiBuddhistEra.scala # core/shared/src/main/scala/org/threeten/bp/format/DateTimeFormatter.scala # core/shared/src/main/scala/org/threeten/bp/format/DateTimeFormatterBuilder.scala # core/shared/src/main/scala/org/threeten/bp/format/DecimalStyle.scala # core/shared/src/main/scala/org/threeten/bp/format/FormatStyle.scala # core/shared/src/main/scala/org/threeten/bp/format/ResolverStyle.scala # core/shared/src/main/scala/org/threeten/bp/format/SignStyle.scala # core/shared/src/main/scala/org/threeten/bp/format/SimpleDateTimeFormatStyleProvider.scala # core/shared/src/main/scala/org/threeten/bp/format/TextStyle.scala # core/shared/src/main/scala/org/threeten/bp/format/internal/TTBPDateTimeFormatterBuilder.scala # core/shared/src/main/scala/org/threeten/bp/format/internal/TTBPDateTimeTextProvider.scala # core/shared/src/main/scala/org/threeten/bp/temporal/ChronoField.scala # core/shared/src/main/scala/org/threeten/bp/temporal/ChronoUnit.scala # core/shared/src/main/scala/org/threeten/bp/temporal/IsoFields.scala # core/shared/src/main/scala/org/threeten/bp/temporal/JulianFields.scala # core/shared/src/main/scala/org/threeten/bp/temporal/TemporalAdjusters.scala # core/shared/src/main/scala/org/threeten/bp/temporal/WeekFields.scala # core/shared/src/main/scala/org/threeten/bp/zone/ZoneOffsetTransitionRule.scala # core/shared/src/main/scala/org/threeten/bp/zone/ZoneRulesInitializer.scala # core/shared/src/main/scala/org/threeten/bp/zone/ZoneRulesProvider.scala
2 parents f8cc387 + dfe7a97 commit 250ae4d

File tree

9 files changed

+131
-26
lines changed

9 files changed

+131
-26
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [master]
5+
tags: ["*"]
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: olafurpg/setup-scala@v2
12+
- uses: olafurpg/setup-gpg@v2
13+
- name: Publish
14+
run: csbt ci-release
15+
env:
16+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
17+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
18+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
19+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

.github/workflows/scala.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: Set up JDK 1.8
12+
uses: olafurpg/setup-scala@v2
13+
with:
14+
java-version: 1.8
15+
- name: Cache Coursier
16+
uses: actions/cache@v1
17+
with:
18+
path: ~/.cache/coursier
19+
key: sbt-coursier-cache
20+
- name: Cache SBT
21+
uses: actions/cache@v1
22+
with:
23+
path: ~/.sbt
24+
key: sbt-${{ hashFiles('**/build.sbt') }}
25+
- name: Checking your code format
26+
run: csbt scalafmtCheckAll
27+
- name: Run tests
28+
run: |
29+
csbt clean +scalajavatimeTestsJVM/test +scalajavatimeTestsJS/test

.scalafmt.conf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version = "2.4.2"
2+
style = default
3+
4+
maxColumn = 100
5+
6+
// Vertical alignment is pretty, but leads to bigger diffs
7+
align = most
8+
9+
rewrite.rules = [
10+
AvoidInfix
11+
RedundantBraces
12+
RedundantParens
13+
AsciiSortImports
14+
PreferCurlyFors
15+
]
16+
17+
align.tokens.add = [{code = "=>", owner = "Case"}]
18+
align.tokens.add = [{code = ":", owner = "Term.Param"}, "=", "shouldBe", "<-", "^"]
19+
align.openParenCallSite = true
20+
spaces.inImportCurlyBraces = true
21+
22+
continuationIndent.defnSite = 2
23+
24+
rewrite.neverInfix.excludeFilters = [until
25+
to
26+
by
27+
eq
28+
ne
29+
"should.*"
30+
"contain.*"
31+
"must.*"
32+
in
33+
be
34+
taggedAs
35+
thrownBy
36+
synchronized
37+
have
38+
when
39+
size
40+
theSameElementsAs]

core/shared/src/main/scala/org/threeten/bp/Month.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object Month {
125125
/** The singleton instance for the month of November with 30 days.
126126
* This has the numeric value of {@code 11}.
127127
*/
128-
lazy val NOVEMBER = new Month("NOVEMBER", 10)
128+
val NOVEMBER = new Month("NOVEMBER", 10)
129129

130130
/** The singleton instance for the month of December with 31 days.
131131
* This has the numeric value of {@code 12}.

core/shared/src/main/scala/org/threeten/bp/chrono/HijrahDate.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ object HijrahDate {
7979
/** 0-based, for number of day-of-year in the beginning of month in normal
8080
* year.
8181
*/
82-
private lazy val NUM_DAYS: Array[Int] =
83-
Array(0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325)
82+
private lazy val NUM_DAYS: Array[Int] = Array(0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325)
8483

8584
/** 0-based, for number of day-of-year in the beginning of month in leap year. */
8685
private lazy val LEAP_NUM_DAYS: Array[Int] =
@@ -90,8 +89,7 @@ object HijrahDate {
9089
private lazy val MONTH_LENGTH: Array[Int] = Array(30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29)
9190

9291
/** 0-based, for day-of-month in leap year. */
93-
private lazy val LEAP_MONTH_LENGTH: Array[Int] =
94-
Array(30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30)
92+
private lazy val LEAP_MONTH_LENGTH: Array[Int] = Array(30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30)
9593

9694
/** <pre>
9795
* Greatest Least

core/shared/src/main/scala/org/threeten/bp/format/DateTimeFormatter.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ object DateTimeFormatter {
8282
* This is pre-padded by zero to ensure two digits.
8383
* </ul><p>
8484
*/
85-
lazy val ISO_LOCAL_DATE: DateTimeFormatter = new DateTimeFormatterBuilder()
85+
val lazy ISO_LOCAL_DATE: DateTimeFormatter = new DateTimeFormatterBuilder()
8686
.appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
8787
.appendLiteral('-')
8888
.appendValue(MONTH_OF_YEAR, 2)
@@ -218,13 +218,12 @@ object DateTimeFormatter {
218218
* <li>The {@link #ISO_LOCAL_TIME}
219219
* </ul><p>
220220
*/
221-
lazy val ISO_LOCAL_DATE_TIME: DateTimeFormatter =
222-
new DateTimeFormatterBuilder().parseCaseInsensitive
223-
.append(ISO_LOCAL_DATE)
224-
.appendLiteral('T')
225-
.append(ISO_LOCAL_TIME)
226-
.toFormatter(ResolverStyle.STRICT)
227-
.withChronology(IsoChronology.INSTANCE)
221+
lazy val ISO_LOCAL_DATE_TIME: DateTimeFormatter = new DateTimeFormatterBuilder().parseCaseInsensitive
222+
.append(ISO_LOCAL_DATE)
223+
.appendLiteral('T')
224+
.append(ISO_LOCAL_TIME)
225+
.toFormatter(ResolverStyle.STRICT)
226+
.withChronology(IsoChronology.INSTANCE)
228227

229228
/** Returns the ISO date formatter that prints/parses a date-time
230229
* with an offset, such as '2011-12-03T10:15:30+01:00'.
@@ -239,12 +238,11 @@ object DateTimeFormatter {
239238
* Parsing is case insensitive.
240239
* </ul><p>
241240
*/
242-
lazy val ISO_OFFSET_DATE_TIME: DateTimeFormatter =
243-
new DateTimeFormatterBuilder().parseCaseInsensitive
244-
.append(ISO_LOCAL_DATE_TIME)
245-
.appendOffsetId
246-
.toFormatter(ResolverStyle.STRICT)
247-
.withChronology(IsoChronology.INSTANCE)
241+
lazy val ISO_OFFSET_DATE_TIME: DateTimeFormatter = new DateTimeFormatterBuilder().parseCaseInsensitive
242+
.append(ISO_LOCAL_DATE_TIME)
243+
.appendOffsetId
244+
.toFormatter(ResolverStyle.STRICT)
245+
.withChronology(IsoChronology.INSTANCE)
248246

249247
/** Returns the ISO date formatter that prints/parses a date-time with
250248
* offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'.

core/shared/src/main/scala/org/threeten/bp/temporal/ChronoField.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ object ChronoField {
137137
* When this field is used for setting a value, it should behave in the same way as
138138
* setting {@link #NANO_OF_SECOND} with the value multiplied by 1,000,000.
139139
*/
140-
lazy val MILLI_OF_SECOND =
141-
new ChronoField("MilliOfSecond", 4, MILLIS, SECONDS, ValueRange.of(0, 999))
140+
lazy val MILLI_OF_SECOND = new ChronoField("MilliOfSecond", 4, MILLIS, SECONDS, ValueRange.of(0, 999))
142141

143142
/** The milli-of-day.
144143
*
@@ -168,8 +167,7 @@ object ChronoField {
168167
* This counts the second within the day, from 0 to (24 * 60 * 60) - 1.
169168
* This field has the same meaning for all calendar systems.
170169
*/
171-
lazy val SECOND_OF_DAY =
172-
new ChronoField("SecondOfDay", 7, SECONDS, DAYS, ValueRange.of(0, 86400L - 1))
170+
lazy val SECOND_OF_DAY = new ChronoField("SecondOfDay", 7, SECONDS, DAYS, ValueRange.of(0, 86400L - 1))
173171

174172
/** The minute-of-hour.
175173
*
@@ -217,8 +215,7 @@ object ChronoField {
217215
* This is the hour that would be observed on a 24-hour analog wall clock.
218216
* This field has the same meaning for all calendar systems.
219217
*/
220-
lazy val CLOCK_HOUR_OF_DAY =
221-
new ChronoField("ClockHourOfDay", 13, HOURS, DAYS, ValueRange.of(1, 24))
218+
lazy val CLOCK_HOUR_OF_DAY = new ChronoField("ClockHourOfDay", 13, HOURS, DAYS, ValueRange.of(1, 24))
222219

223220
/** The am-pm-of-day.
224221
*

core/shared/src/main/scala/org/threeten/bp/temporal/IsoFields.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ object IsoFields {
266266
}
267267
}
268268

269-
lazy val QUARTER_OF_YEAR: Field = new Field("QUARTER_OF_YEAR", 1) {
269+
lazy val QUARTER_OF_YEAR: Field = new Field("QUARTER_OF_YEAR", 1) {
270270
override def toString: String = "QuarterOfYear"
271271
def getBaseUnit: TemporalUnit = QUARTER_YEARS
272272
def getRangeUnit: TemporalUnit = YEARS
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package demo
2+
3+
import java.time.{ Instant, LocalDateTime, OffsetDateTime, ZoneId }
4+
import java.time.zone.ZoneRulesProvider
5+
import java.time.format._
6+
// import java.util.Locale
7+
8+
object DemoApp {
9+
def main(args: Array[String]): Unit = {
10+
println(LocalDateTime.ofInstant(Instant.now, ZoneId.systemDefault).toString())
11+
println(ZoneRulesProvider.getAvailableZoneIds)
12+
// Locale.setDefault(Locale.forLanguageTag("fi-FI"))
13+
val instant = Instant.ofEpochMilli(0)
14+
val datetime = LocalDateTime.ofInstant(Instant.now, ZoneId.of("Europe/Helsinki"))
15+
val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")
16+
val odt =
17+
OffsetDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME)
18+
val strRepl = odt.format(formatter)
19+
println(instant)
20+
println(datetime)
21+
println(strRepl)
22+
println(odt)
23+
}
24+
}

0 commit comments

Comments
 (0)