Skip to content

Commit e13913d

Browse files
committed
Integrate demo
Signed-off-by: Carlos Quiroz <[email protected]>
1 parent b4ad07f commit e13913d

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

build.sbt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import sbtcrossproject.CrossPlugin.autoImport.{ CrossType, crossProject }
22
import sbt._
33
import sbt.io.Using
44

5-
val scalaVer = "2.12.10"
5+
val scalaVer = "2.13.1"
66
val tzdbVersion = "2019c"
7-
val scalaJavaTimeVer = "2.0.0-RC4-SNAPSHOT"
8-
val scalaJavaTimeVersion = s"$scalaJavaTimeVer"
9-
val scalaTZDBVersion = s"${scalaJavaTimeVer}_$tzdbVersion"
7+
val scalaJavaTimeVersion = "2.0.0-RC4-SNAPSHOT"
8+
val scalaTZDBVersion = s"${scalaJavaTimeVersion}_$tzdbVersion"
109

1110
Global / onChangedBuildSource := ReloadOnSourceChanges
1211

@@ -74,7 +73,8 @@ lazy val root = project
7473
scalajavatimeTZDBJVM,
7574
scalajavatimeTZDBJS,
7675
scalajavatimeTestsJVM,
77-
scalajavatimeTestsJVM)
76+
scalajavatimeTestsJVM,
77+
demo)
7878

7979
/**
8080
* Copy source files and translate them to the java.time package
@@ -215,6 +215,26 @@ lazy val scalajavatimeTests = crossProject(JVMPlatform, JSPlatform)
215215
lazy val scalajavatimeTestsJVM = scalajavatimeTests.jvm
216216
lazy val scalajavatimeTestsJS = scalajavatimeTests.js
217217

218+
val zonesFilterFn = (x: String) => {
219+
x == "Europe/Helsinki" || x == "America/Santiago"
220+
}
221+
222+
lazy val demo = project
223+
.in(file("demo"))
224+
.dependsOn(scalajavatime.js)
225+
.enablePlugins(ScalaJSPlugin)
226+
.enablePlugins(TzdbPlugin)
227+
.settings(
228+
scalaVersion := scalaVer,
229+
name := "demo",
230+
publish := {},
231+
publishLocal := {},
232+
publishArtifact := false,
233+
Keys.`package` := file(""),
234+
scalaJSUseMainModuleInitializer := true,
235+
zonesFilter := zonesFilterFn
236+
)
237+
218238
lazy val docs = project
219239
.in(file("docs"))
220240
.dependsOn(scalajavatime.jvm, scalajavatime.js)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package demo
2+
3+
import java.time.{OffsetDateTime, Instant, LocalDateTime, 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 = OffsetDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME)
17+
val strRepl = odt.format(formatter)
18+
println(instant)
19+
println(datetime)
20+
println(strRepl)
21+
println(odt)
22+
}
23+
}

0 commit comments

Comments
 (0)