• Stars
    star
    327
  • Rank 127,897 (Top 3 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An intuitive Date extensions in Kotlin.

khronos

Build Status Download License

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

${latest.version} = Download

dependencies {
  compile 'com.github.hotchemi:khronos:${latest.version}'
}

Notice

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.

More Repositories

1

awesome-android-testing

A curated list of awesome android testing libraries.
744
star
2

Android-Rate

Android-Rate is a library to help you promote your android app by prompting users to rate the app after using it for a few days.
Java
726
star
3

gradle-proguard-plugin

The gradle plugin to add proguard snippets to your proguard setting file quickly.
Groovy
86
star
4

LruCache

A tiny memory cache implementation which uses a LRU policy.
Java
76
star
5

ProgressMenuItem

Shows and stop a progress in the ActionBar.
Java
75
star
6

Scre

A lightweight screen recorder macOS application written in SwiftUI.
Swift
69
star
7

tiamat

Reactive SharedPreferences code generator for Android.
Java
69
star
8

StringPicker

StringPicker is a library to provides a custom view and dialog fragment to pick string value.
Java
50
star
9

m-permissions-checker

You can check whether you have to handle your app permission or not in Android M.
Python
49
star
10

awesome-recruit-engineer-careers

リクルートグループのエンジニア採用情報
46
star
11

mvns

CLI tool to search library in maven central repository
Python
20
star
12

wearzaim

Zaim Android Wear Client.
Java
18
star
13

zaim.js

Node.js library for the Zaim API.
TypeScript
16
star
14

kotlin-compiler-plugin-example

Kotlin
14
star
15

vscode-find-pr

A vscode plugin jumps to pull request url.
TypeScript
13
star
16

IdeaTweet

simple tweet plugin for jetbrains ide.
Java
10
star
17

deploygate-maven-plugin

DeployGate plugin for maven.
Java
6
star
18

redpen-android

RedPen android client(unofficial).
Java
5
star
19

android.casual

5
star
20

picasso-helper

DEPRECATED
Java
4
star
21

private.js

Provides private accessor to javascript object.
JavaScript
4
star
22

youroom4j

youRoom4J is a Java library for the youRoom API.
Java
3
star
23

zaim-cli

CLI based Zaim client
JavaScript
2
star
24

surl

Shorten an url in your clipboard.
Go
2
star
25

EasyButton

Custom button set background color easily.
Shell
2
star
26

HeckelDiff

Kotlin
2
star
27

tqkey-groovy

Groovy
2
star
28

goodjob_notifier

JavaScript
1
star
29

Pio

Twitter client focus only on tweet
JavaScript
1
star
30

everRoom

save daily yourrom to evernote.
CSS
1
star
31

NetImageView

Java
1
star
32

clasp-template

TypeScript
1
star
33

performance-list-manipulation

Java
1
star