Skip to content

Commit

Permalink
Added day and week duration exts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carleslc committed Jul 30, 2017
1 parent 8e7e477 commit ec8939c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Add the following dependencies to your `pom.xml`:
<dependency>
<groupId>com.github.carleslc</groupId>
<artifactId>kotlin-extensions</artifactId>
<version>0.6</version>
<version>0.6.1</version>
</dependency>
</dependencies>
```
Expand All @@ -42,7 +42,7 @@ repositories {
Add the following dependency to your `build.gradle`:
```
dependencies {
compile 'com.github.carleslc:kotlin-extensions:0.6'
compile 'com.github.carleslc:kotlin-extensions:0.6.1'
}
```

Expand All @@ -56,7 +56,7 @@ If you need more powerful extensions and tools check the [optional libraries sec

If you wish, you can use these steps to add the dependency using Maven or Gradle without accessing to the `jitpack.io` remote repository.

Otherwise you will need to add the `kotlin-extensions-0.6.jar` from generated `target` folder as external dependency of your project.
Otherwise you will need to add the `kotlin-extensions-0.6.1.jar` from generated `target` folder as external dependency of your project.

If you need more powerful extensions and tools check the [optional libraries section](https://github.com/Carleslc/kotlin-extensions#optional-libraries).

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>me.carleslc</groupId>
<artifactId>kotlin-extensions</artifactId>
<version>0.6</version>
<version>0.6.1</version>
<packaging>jar</packaging>

<name>KotlinExtensions</name>
Expand Down
12 changes: 12 additions & 0 deletions src/me/carleslc/kotlin/extensions/time/TimeExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ inline val Long.minute: Duration get() = minutes
inline val Long.hours: Duration get() = run(Duration::ofHours)
inline val Long.hour: Duration get() = hours

inline val Long.daysDuration: Duration get() = toInt().daysDuration
inline val Long.dayDuration: Duration get() = daysDuration

inline val Long.weeksDuration: Duration get() = toInt().weeksDuration
inline val Long.weekDuration: Duration get() = weeksDuration

inline val Long.days: Period get() = toInt().days
inline val Long.day: Period get() = days

Expand Down Expand Up @@ -159,6 +165,12 @@ inline val Int.minute: Duration get() = minutes
inline val Int.hours: Duration get() = toLong().hours
inline val Int.hour: Duration get() = hours

inline val Int.daysDuration: Duration get() = (24 * this).hours
inline val Int.dayDuration: Duration get() = daysDuration

inline val Int.weeksDuration: Duration get() = (24 * 7 * this).hours
inline val Int.weekDuration: Duration get() = weeksDuration

inline val Int.days: Period get() = run(Period::ofDays)
inline val Int.day: Period get() = days

Expand Down

0 comments on commit ec8939c

Please sign in to comment.