Skip to content

Commit 956a838

Browse files
authored
Merge pull request #2 from cquiroz/microsite
Microsite
2 parents 26f6a0c + fb6b6b1 commit 956a838

File tree

5 files changed

+148
-92
lines changed

5 files changed

+148
-92
lines changed

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ jdk:
1010
- oraclejdk8
1111

1212
scala:
13+
- 2.10.6
1314
- 2.11.8
15+
- 2.12.0
16+
17+
before_install:
18+
- export PATH=${PATH}:./vendor/bundle
19+
20+
install:
21+
- rvm use 2.2.3 --install --fuzzy
22+
- gem update --system
23+
- gem install sass
24+
- gem install jekyll -v 3.2.1
1425

1526
cache:
1627
directories:
@@ -23,6 +34,7 @@ env:
2334

2435
script:
2536
- sbt scalajavatimeJVM/test scalajavatimeJS/test
37+
- sbt docs/makeMicrosite
2638
#- sbt clean coverage test &&
2739
# sbt coverageAggregate
2840
after_success:

README.md

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,6 @@
88
This project provides an implementation of the `java.time` package, a date and time library that was added in Java 8.
99
The implementation is based on the original BSD-licensed reference implementation (before it was contributed to OpenJDK).
1010

11-
#### Example
12-
13-
```scala
14-
import org.threeten.bp._
15-
16-
// always returns 2009-02-13T23:31:30
17-
val fixedClock = Clock.fixed(Instant.ofEpochSecond(1234567890L), ZoneOffset.ofHours(0))
18-
val date = LocalDateTime.now(fixedClock)
19-
20-
date.getMonth == Month.FEBRUARY
21-
date.getDayOfWeek == DayOfWeek.FRIDAY
22-
date.getDayOfMonth == 13
23-
date.getHour == 23
24-
25-
val tomorrow = date.plusDays(1)
26-
27-
val duration = Duration.between(date, tomorrow)
28-
duration.toMinutes == 1440L
29-
30-
val period = Period.between(date.toLocalDate, tomorrow.toLocalDate)
31-
period.get(temporal.ChronoUnit.DAYS) == 1L
32-
33-
val date1 = LocalDate.of(2001, 1, 31)
34-
date1.plusMonths(1) == LocalDate.of(2001, 2, 28)
35-
val date2 = date1.`with`(temporal.TemporalAdjusters.next(DayOfWeek.SUNDAY))
36-
date2 == LocalDate.of(2001, 2, 4)
37-
38-
val offsetTime = OffsetTime.of(date.toLocalTime, ZoneOffset.ofHours(1))
39-
offsetTime.isBefore(OffsetTime.of(date.toLocalTime, ZoneOffset.ofHours(0))) == true
40-
41-
val format1 = format.DateTimeFormatter.ofPattern("MMMM MM d HH mm ss EE EEEE yyyy G", java.util.Locale.GERMAN)
42-
date.format(format1) == "Februar 02 13 23 31 30 Fr. Freitag 2009 n. Chr."
43-
44-
chrono.JapaneseDate.now(fixedClock).toString == "Japanese Heisei 21-02-13"
45-
chrono.ThaiBuddhistDate.now(fixedClock).toString == "ThaiBuddhist BE 2552-02-13"
46-
chrono.MinguoDate.now(fixedClock).toString == "Minguo ROC 98-02-13"
47-
```
48-
4911
#### Usage
5012

5113
The *scala-java-time* library is currently available for Scala (JVM, version 8 and later) and Scala.js (JavaScript).
@@ -56,58 +18,6 @@ To get started with SBT, add one (or both) of these dependencies:
5618
- `libraryDependencies += "com.github.cquiroz" % "scala-java-time" % "2.0.0-M5"` (for Scala)
5719
- `libraryDependencies += "com.github.cquiroz" %%% "scala-java-time" % "2.0.0-M5"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
5820

59-
#### Building
60-
This project builds using sbt.
61-
Run `sbt scalajavatimeCrossJVM/test` to run the test suite on the JVM and
62-
`sbt scalajavatimeCrossJS/test` to run the test suite in JavaScript.
63-
64-
#### Status
65-
66-
Most parts of this library work perfectly fine with Scala.js in the browser.
67-
Locale, formatting and timezone support is limited and providing these missing pieces are the current focus of this project.
68-
@cquiroz is currently working on implementing locale support.
69-
70-
#### Contributing
71-
72-
We welcome all contributions, including ideas, suggestions, bug reports, bug fixes and code!
73-
We are especially interested in contributions that tackle the following issues:
74-
75-
- *Support for formatting:* Formatting uses a lot of JDK classes, which we might not want to reimplement in Scala.js.
76-
We might be able to use the new `Intl` Web API.
77-
- *Support for timezones:* The timezone information is read from a binary blob, which won't work in the browser.
78-
We will have a look at other projects like moment.js and decide whether we want to use the same format, or come up with our own.
79-
80-
Have a look at the [issues](https://github.com/cquiroz/scala-java-time/issues) or [issues](https://github.com/soc/scala-java-time/issues) to find something to work on! Let us know if you need help!
81-
82-
#### Plans
83-
84-
##### 2.0
85-
86-
We will keep releasing milestone builds while work on the remaining bits and pieces to support 100% of this library on Scala.js is ongoing (most parts work fine already).
87-
88-
The last milestone will rename the package name from `org.threeten.bp` to `java.time`.
89-
90-
A stable release of 2.0 will be published after a (hopefully) short RC phase.
91-
92-
##### 3.0
93-
94-
As soon as Scala-Native provides cross-compilation capabilities we will investigate what's necessary to compile this library to native code.
95-
96-
#### Time-zone data
97-
The time-zone database is stored as a pre-compiled dat file that is included in the built jar.
98-
The version of the time-zone data used is stored within the dat file (near the start).
99-
Updating the time-zone database involves using the `TzdbZoneRulesCompiler` class
100-
and re-compiling the jar file.
101-
Pull requests with later versions of the dat file will be accepted.
102-
103-
#### FAQs
104-
105-
##### Is this project derived from OpenJDK?
106-
107-
No. This project is derived from the Reference Implementation previously hosted on GitHub.
108-
That project had a BSD license, which has been preserved here.
109-
Thus, this project is a fork of the original code before entry to OpenJDK.
110-
111-
##### What is the relation to [this](https://github.com/soc/scala-java-time/) project
21+
#### Documentation
11222

113-
This is a fork from the original [project](https://github.com/soc/scala-java-time/) aim to complete the API to work on Scala.js
23+
See the [documentation](http://cquiroz.github.io/scala-java-time/)

build.sbt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import sbt._
22

33
import io.github.soc.testng.{TestNGPlugin, TestNGScalaJSPlugin}
44

5+
enablePlugins(MicrositesPlugin)
6+
57
val scalaVer = "2.11.8"
68
val crossScalaVer = Seq(scalaVer, "2.10.6", "2.12.0")
79

810
lazy val commonSettings = Seq(
911
name := "scala-java-time",
12+
description := "java.time API implementation in Scala and Scala.js",
1013
version := "2.0.0-M5",
1114
organization := "com.github.cquiroz",
1215
homepage := Some(url("https://github.com/cquiroz/scala-java-time")),
@@ -30,6 +33,7 @@ lazy val commonSettings = Seq(
3033

3134
lazy val root = project.in(file("."))
3235
.aggregate(scalajavatimeJVM, scalajavatimeJS)
36+
.enablePlugins(MicrositesPlugin)
3337
.settings(
3438
scalaVersion := scalaVer,
3539
crossScalaVersions := crossScalaVer,
@@ -48,6 +52,8 @@ lazy val scalajavatime = crossProject.crossType(CrossType.Full).in(file("."))
4852
.jsConfigure(_.enablePlugins(TestNGScalaJSPlugin))
4953
.settings(commonSettings: _*)
5054
.jvmSettings(
55+
micrositeExtraMdFiles := Map(file("README.md") -> "index.md"),
56+
5157
resolvers += Resolver.sbtPluginRepo("releases"),
5258
// Fork the JVM test to ensure that the custom flags are set
5359
fork in Test := true,
@@ -65,6 +71,20 @@ lazy val scalajavatime = crossProject.crossType(CrossType.Full).in(file("."))
6571
lazy val scalajavatimeJVM = scalajavatime.jvm
6672
lazy val scalajavatimeJS = scalajavatime.js
6773

74+
lazy val docs = project.in(file("docs")).dependsOn(scalajavatimeJVM, scalajavatimeJS)
75+
.settings(commonSettings)
76+
.settings(name := "docs")
77+
.enablePlugins(MicrositesPlugin)
78+
.settings(
79+
micrositeName := "scala-java-time",
80+
micrositeAuthor := "Carlos Quiroz",
81+
micrositeGithubOwner := "cquiroz",
82+
micrositeGithubRepo := "scala-java-time",
83+
micrositeBaseUrl := "/scala-java-time",
84+
//micrositeDocumentationUrl := "/scala-java-time/docs/",
85+
micrositeHighlightTheme := "color-brewer"
86+
)
87+
6888
lazy val pomData =
6989
<scm>
7090
<url>git@github.com:cquiroz/scala-java-time.git</url>

docs/src/main/tut/index.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
layout: home
3+
title: "scala-java-time"
4+
section: "home"
5+
---
6+
7+
## Scala Java-Time
8+
9+
[![Build Status](https://travis-ci.org/cquiroz/scala-java-time.svg?branch=master)](https://travis-ci.org/cquiroz/scala-java-time)
10+
[![Maven Central](https://img.shields.io/maven-central/v/io.github.cquiroz/scala-java-time_2.11.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.cquiroz/scala-java-time_2.11)
11+
[![Scala.js](http://scala-js.org/assets/badges/scalajs-0.6.8.svg)](http://scala-js.org)
12+
13+
This project provides an implementation of the `java.time` package, a date and time library that was added in Java 8.
14+
The implementation is based on the original BSD-licensed reference implementation (before it was contributed to OpenJDK).
15+
16+
#### Example
17+
18+
```tut:book
19+
// You can pick either java.time or org.threeten.bp package to import
20+
import java.time._
21+
22+
// always returns 2009-02-13T23:31:30
23+
val fixedClock = Clock.fixed(Instant.ofEpochSecond(1234567890L), ZoneOffset.ofHours(0))
24+
val date = LocalDateTime.now(fixedClock)
25+
26+
date.getMonth == Month.FEBRUARY
27+
date.getDayOfWeek == DayOfWeek.FRIDAY
28+
date.getDayOfMonth == 13
29+
date.getHour == 23
30+
31+
val tomorrow = date.plusDays(1)
32+
33+
val duration = Duration.between(date, tomorrow)
34+
duration.toMinutes == 1440L
35+
36+
val period = Period.between(date.toLocalDate, tomorrow.toLocalDate)
37+
period.get(temporal.ChronoUnit.DAYS) == 1L
38+
39+
val date1 = LocalDate.of(2001, 1, 31)
40+
date1.plusMonths(1) == LocalDate.of(2001, 2, 28)
41+
val date2 = date1.`with`(temporal.TemporalAdjusters.next(DayOfWeek.SUNDAY))
42+
date2 == LocalDate.of(2001, 2, 4)
43+
44+
val offsetTime = OffsetTime.of(date.toLocalTime, ZoneOffset.ofHours(1))
45+
offsetTime.isBefore(OffsetTime.of(date.toLocalTime, ZoneOffset.ofHours(0))) == true
46+
47+
val format1 = format.DateTimeFormatter.ofPattern("MMMM MM d HH mm ss EE EEEE yyyy G", java.util.Locale.GERMAN)
48+
date.format(format1) == "Februar 02 13 23 31 30 Fr. Freitag 2009 n. Chr."
49+
50+
chrono.JapaneseDate.now(fixedClock).toString == "Japanese Heisei 21-02-13"
51+
chrono.ThaiBuddhistDate.now(fixedClock).toString == "ThaiBuddhist BE 2552-02-13"
52+
chrono.MinguoDate.now(fixedClock).toString == "Minguo ROC 98-02-13"
53+
```
54+
55+
#### Usage
56+
57+
The *scala-java-time* library is currently available for Scala (JVM, version 8 and later) and Scala.js (JavaScript).
58+
Both Scala 2.11 and Scala 2.12 (2.12.0-M6 and later) are supported.
59+
60+
To get started with SBT, add one (or both) of these dependencies:
61+
62+
- `libraryDependencies += "io.github.cquiroz" % "scala-java-time" % "2.0.0-M6"` (for Scala)
63+
- `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M6"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
64+
65+
#### Building
66+
This project builds using sbt.
67+
Run `sbt scalajavatimeCrossJVM/test` to run the test suite on the JVM and
68+
`sbt scalajavatimeCrossJS/test` to run the test suite in JavaScript.
69+
70+
#### Status
71+
72+
Most parts of this library work perfectly fine with Scala.js in the browser.
73+
timezone support is limited and providing these missing pieces are the current focus of this project.
74+
75+
#### Contributing
76+
77+
We welcome all contributions, including ideas, suggestions, bug reports, bug fixes and code!
78+
We are especially interested in contributions that tackle the following issues:
79+
80+
- *Support for timezones:* The timezone information is read from a binary blob, which won't work in the browser.
81+
We will have a look at other projects like moment.js and decide whether we want to use the same format, or come up with our own.
82+
83+
Have a look at the [issues](https://github.com/cquiroz/scala-java-time/issues) or [issues](https://github.com/soc/scala-java-time/issues) to find something to work on! Let us know if you need help!
84+
85+
#### Plans
86+
87+
##### 2.0
88+
89+
We will keep releasing milestone builds while work on the remaining bits and pieces to support 100% of this library on Scala.js is ongoing (most parts work fine already).
90+
91+
The current version is published containing the code in both packages: `org.threeten.bp` and `java.time`.
92+
93+
A stable release of 2.0 will be published after a (hopefully) short RC phase.
94+
95+
#### Time-zone data (JVM)
96+
The time-zone database is stored as a pre-compiled dat file that is included in the built jar.
97+
The version of the time-zone data used is stored within the dat file (near the start).
98+
Updating the time-zone database involves using the `TzdbZoneRulesCompiler` class
99+
and re-compiling the jar file.
100+
Pull requests with later versions of the dat file will be accepted.
101+
102+
#### FAQs
103+
104+
##### Is this project derived from OpenJDK?
105+
106+
No. This project is derived from the Reference Implementation previously hosted on GitHub.
107+
That project had a BSD license, which has been preserved here.
108+
Thus, this project is a fork of the original code before entry to OpenJDK.
109+
110+
##### What is the relation to [this](https://github.com/soc/scala-java-time/) project
111+
112+
This is a fork from the original [project](https://github.com/soc/scala-java-time/) aim to complete the API to work on Scala.js

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
44
addSbtPlugin("io.github.soc" % "sbt-testng" % "4.0.0-M3")
55
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M14-7")
66

7+
addSbtPlugin("com.fortysevendeg" % "sbt-microsites" % "0.3.3")
8+
79
// Incompatible with 2.12.0-M5
810
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5")
911
// addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")

0 commit comments

Comments
 (0)