Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - hotchemi/khronos: An intuitive Date extensions in Kotlin.
An intuitive Date extensions in Kotlin. Contribute to hotchemi/khronos development by creating an account on GitHub.
Visit SiteGitHub - hotchemi/khronos: An intuitive Date extensions in Kotlin.
An intuitive Date extensions in Kotlin. Contribute to hotchemi/khronos development by creating an account on GitHub.
Powered by 0x5a.live ๐
khronos
An intuitive Date extensions in Kotlin.
Usage
Add durations to date
val today = Dates.today
val nextWeek = today + 1.week
val dayBeforeYesterday = today - 2.days
// shortcuts #1
val tomorrow = Dates.tomorrow
val yesterday = Dates.yesterday
// shortcuts #2
val yesterday = 1.days.ago
val fiveYearsSince = 5.years.since
Initialize by specifying date components
val birthday = Dates.of(year = 1990, month = 1, day = 21)
val firstCommitDate = Dates.of(year = 2016, month = 2, day = 26, hour = 18, minute = 58, second = 31, millisecond = 777)
Initialize by changing date components
val today = Dates.today
val christmas = today.with(month = 12, day = 25)
val thisSunday = today.with(weekday = 1)
// shortcuts
val newYearDay = today.beginningOfYear
val newYearsEve = today.endOfYear
Check day of the week
Dates.today.isFriday() // false
Format and parse
5.minutes.since.toString("yyyy-MM-dd HH:mm:ss")
//=> "2015-03-01 12:05:00"
"1987-06-02".toDate("yyyy-MM-dd")
//=> Dates.of(year = 1987, month = 6, day = 2)
Compare dates
1.day.ago > 2.days.ago // true
1.day.ago in 2.days.ago..Dates.today // true
Install
dependencies {
compile 'com.github.hotchemi:khronos:${latest.version}'
}
Notice
- khronos is definitely inspired by naoty/Timepiece(Swift).
Licence
Copyright 2016 Shintaro Katafuchi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Kotlin Resources
are all listed below.
GitHub - BenWoodworth/knbt: Kotlin NBT library for kotlinx.serialization
resource
~/github.com
resource
GitHub - brianmadden/krawler: A web crawling framework written in Kotlin
resource
~/github.com
resource
GitHub - OxygenCobalt/Auxio: A simple, rational music player for android
resource
~/github.com
resource
GitHub - eriksencosta/math-percentage: Percentage calculations made easy
resource
~/github.com
resource
GitHub - ctripcorp/mmkv-kotlin: A Kotlin Multiplatform porting for MMKV.
resource
~/github.com
resource
GitHub - Litote/kmongo: [deprecated] KMongo - a Kotlin toolkit for Mongo
resource
~/github.com
resource
Test-Driven Development Tutorial for Android: Getting Started
resource
~/www.raywenderlich.com
resource
GitHub - jacinpoz/rxaerospike: RxJava2 wrapper for aerospike-client-java
resource
~/github.com
resource
GitHub - pedrovgs/KotlinSnapshot: Snapshot Testing framework for Kotlin.
resource
~/github.com
resource
GitHub - hankdavidson/ktime: kotlin extensions to the java8 time library
resource
~/github.com
resource
GitHub - ziggy42/Blum: A simple android Twitter client written in Kotlin
resource
~/github.com
resource
Made with โค๏ธ
to provide different kinds of informations and resources.