@@ -5,17 +5,31 @@ Consistent and portable date and time utilities for multiplatform kotlin (JVM, J
5
5
[ ![ Build Status] ( https://travis-ci.org/korlibs/klock.svg?branch=master )] ( https://travis-ci.org/korlibs/klock )
6
6
[ ![ Maven Version] ( https://img.shields.io/github/tag/korlibs/klock.svg?style=flat&label=maven )] ( http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22klock%22 )
7
7
8
- Use with gradle (uploaded to maven central ):
8
+ Use with gradle (uploaded to bintray and synchronized to jcenter ):
9
9
10
10
```
11
- compile "com.soywiz:klock:0.2.0" // jvm/android
12
- compile "com.soywiz:klock-js:0.2.0" // js
13
- compile "com.soywiz:klock-common:0.2.0" // common (just expect 2 decls in Klock)
11
+ def klockVersion = "1.0.0-alpha-1"
12
+
13
+ repositories {
14
+ maven { url "https://dl.bintray.com/soywiz/soywiz" }
15
+ }
16
+
17
+ compile "com.soywiz:klock-jvm:$klockVersion" // JVM/Android
18
+ compile "com.soywiz:klock-js:$klockVersion" // JavaScript
19
+ compile "com.soywiz:klock-iosarm32:$klockVersion" // Older iOS devices
20
+ compile "com.soywiz:klock-iosarm64:$klockVersion" // New iOS devices
21
+ compile "com.soywiz:klock-iosx64:$klockVersion" // Simulator
22
+ compile "com.soywiz:klock-linuxx64:$klockVersion" // Linux x64
23
+ compile "com.soywiz:klock-macosx64:$klockVersion" // MacOS
24
+ compile "com.soywiz:klock-mingwx64:$klockVersion" // Windows x64
25
+ compile "com.soywiz:klock-common:$klockVersion" // Common (just expect 2 decls in Klock)
14
26
```
15
27
16
28
``` kotlin
17
29
object Klock {
18
30
fun currentTimeMillis (): Long
31
+ fun currentTimeMillisDouble (): Double
32
+ fun microClock (): Double
19
33
fun getLocalTimezoneOffset (unix : Long ): Int
20
34
}
21
35
@@ -38,13 +52,21 @@ enum class Month {
38
52
fun daysToEnd (year : Int ): Int
39
53
}
40
54
41
- object Year {
42
- fun isLeap (year : Int ): Boolean
55
+ inline class Year (val year : Int ) : Comparable<Year> {
56
+ companion object {
57
+ fun checked (year : Int ): Year
58
+ fun isLeapChecked (year : Int ): Boolean
59
+ fun isLeap (year : Int ): Boolean
60
+ }
61
+
62
+ override fun compareTo (other : Year ): Int
43
63
}
44
64
65
+
45
66
interface DateTime {
46
67
companion object {
47
68
val EPOCH : DateTime
69
+
48
70
operator fun invoke (year : Int , month : Int , day : Int , hour : Int = 0, minute : Int = 0, second : Int = 0, milliseconds : Int = 0): DateTime
49
71
operator fun invoke (time : Long ): DateTime
50
72
@@ -106,7 +128,7 @@ data class TimeDistance(val years: Int = 0, val months: Int = 0, val days: Doubl
106
128
operator fun times (times : Double ): TimeDistance
107
129
}
108
130
109
- data class TimeSpan {
131
+ inline class TimeSpan {
110
132
val milliseconds: Int
111
133
val seconds: Double
112
134
@@ -131,7 +153,10 @@ inline val Number.milliseconds: TimeSpan
131
153
132
154
class SimplerDateFormat (val format : String ) {
133
155
companion object {
134
- val DEFAULT_FORMAT : SimplerDateFormat // "EEE, dd MMM yyyy HH:mm:ss z"
156
+ val DEFAULT_FORMAT = SimplerDateFormat (" EEE, dd MMM yyyy HH:mm:ss z" )
157
+ val FORMAT1 = SimplerDateFormat (" yyyy-MM-dd'T'HH:mm:ssXXX" )
158
+ val FORMATS = listOf (DEFAULT_FORMAT , FORMAT1 )
159
+ fun parse (str : String ): DateTime
135
160
}
136
161
137
162
fun format (date : Long ): String
0 commit comments