-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from sideeffffect/ZoneMap-for-all-platforms
Add support for Scala Native
- Loading branch information
Showing
4 changed files
with
109 additions
and
45 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
sbt-tzdb/src/main/resources/native/TzdbZoneRulesProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package | ||
|
||
import org.threeten.bp.DateTimeException | ||
|
||
import org.portablescala.reflect.annotation.EnableReflectiveInstantiation | ||
|
||
@EnableReflectiveInstantiation | ||
final class TzdbZoneRulesProvider extends ZoneRulesProvider { | ||
import zonedb.threeten.tzdb._ | ||
|
||
override protected def provideZoneIds: java.util.Set[String] = { | ||
val zones = new java.util.HashSet[String]() | ||
val zonesSet = (stdZones.keySet ++ fixedZones.keySet ++ zoneLinks.keySet) | ||
zonesSet.foreach(zones.add(_)) | ||
// I'm not totallly sure the reason why but TTB removes these ZoneIds | ||
// zones.remove("UTC") | ||
// zones.remove("GMT") | ||
zones.remove("GMT0") | ||
zones.remove("GMT+0") | ||
zones.remove("GMT-0") | ||
zones | ||
} | ||
|
||
override protected def provideRules(regionId: String, | ||
forCaching: Boolean): ZoneRules = { | ||
val actualRegion = zoneLinks.getOrElse(regionId, regionId) | ||
stdZones | ||
.get(actualRegion) | ||
.orElse( | ||
fixedZones | ||
.get(actualRegion)) | ||
.getOrElse( | ||
throw new DateTimeException(s"TimeZone Region $actualRegion unknown")) | ||
} | ||
|
||
override protected def provideVersions( | ||
zoneId: String): java.util.NavigableMap[String, ZoneRules] = { | ||
val actualRegion = zoneLinks.getOrElse(zoneId, zoneId) | ||
stdZones | ||
.get(actualRegion) | ||
.orElse( | ||
fixedZones | ||
.get(actualRegion)) | ||
.map { z => | ||
val r = new ZoneMap[String, ZoneRules] | ||
r.put(version, z) | ||
r | ||
} | ||
.getOrElse( | ||
throw new DateTimeException(s"TimeZone Region $actualRegion unknown")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters