kotlin-date-range

Implementing rangeTo operator for LocalDate and Date in kotlin

Лицензия

Лицензия

Категории

Категории

Kotlin Языки программирования MOA Прикладные библиотеки Machine Learning
Группа

Группа

me.moallemi.tools
Идентификатор

Идентификатор

kotlin-date-range
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

kotlin-date-range
Implementing rangeTo operator for LocalDate and Date in kotlin
Ссылка на сайт

Ссылка на сайт

https://github.com/moallemi/kotlin-date-range
Система контроля версий

Система контроля версий

https://github.com/moallemi/kotlin-date-range

Скачать kotlin-date-range

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/me.moallemi.tools/kotlin-date-range/ -->
<dependency>
    <groupId>me.moallemi.tools</groupId>
    <artifactId>kotlin-date-range</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/me.moallemi.tools/kotlin-date-range/
implementation 'me.moallemi.tools:kotlin-date-range:1.0.0'
// https://jarcasting.com/artifacts/me.moallemi.tools/kotlin-date-range/
implementation ("me.moallemi.tools:kotlin-date-range:1.0.0")
'me.moallemi.tools:kotlin-date-range:jar:1.0.0'
<dependency org="me.moallemi.tools" name="kotlin-date-range" rev="1.0.0">
  <artifact name="kotlin-date-range" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.moallemi.tools', module='kotlin-date-range', version='1.0.0')
)
libraryDependencies += "me.moallemi.tools" % "kotlin-date-range" % "1.0.0"
[me.moallemi.tools/kotlin-date-range "1.0.0"]

Зависимости

runtime (1)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib jar 1.3.70

Модули Проекта

Данный проект не имеет модулей.

Kotlin Date Range

GitHub Workflow Status Maven Central

This is a tiny implementation of rangeTo operator for Date and LocalDate that makes the syntax for loop iteration and control flow statements safe and natural to read.

Installation

Add the kotlin-date-range to your dependencies section:

dependencies {
  implementation 'me.moallemi.tools:kotlin-date-range:1.0.0'
}

How to use

From Java SE 8 onwards, users are asked to migrate to java.time (JSR-310). For Android users, java.time is added in API level 26+. Projects needing to support lower API levels can use java.util.Date.

with java.time.LocalDate

Using rangeTo operator:

import me.moallemi.tools.daterange.localdate.rangeTo

val startDate = LocalDate.of(2020, 3, 22)
val endDate = LocalDate.of(2020, 4, 1)
for (date in startDate..endDate) {
    println(date)
}

Usage with step function:

import me.moallemi.tools.daterange.localdate.rangeTo

val startDate = LocalDate.of(2020, 3, 22)
val endDate = LocalDate.of(2020, 4, 1)
for (date in startDate..endDate step 2) {
    println(date)
}

Using with in operator:

import me.moallemi.tools.daterange.localdate.rangeTo

val startDate = LocalDate.of(2020, 1, 1)
val endDate = LocalDate.of(2020, 1, 5)

val result: Boolean = LocalDate.of(2020, 1, 2) in (startDate..endDate)

with java.util.Date

Using rangeTo operator:

import me.moallemi.tools.daterange.date.rangeTo

val calendar = Calendar.getInstance(Locale.getDefault())
calendar.set(2020, 0, 1)
val startDate = calendar.time
calendar.set(2020, 0, 5)
val endDate = calendar.time
for (date in startDate..endDate) {
    println(date)
}

Usage with step function:

import me.moallemi.tools.daterange.date.rangeTo

for (date in startDate..endDate step 2) {
    println(date)
}

License

Copyright 2020 Reza Moallemi.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you 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.

Версии библиотеки

Версия
1.0.0
0.0.5
0.0.3
0.0.2