Additions for Kotlin's date & time library kotlinx-datetime

Overview

fluid-time

Maven Central Tests Kotlin kotlinx-datetime #fluid-libraries Slack Channel

Additions for Kotlin's date & time library kotlinx-datetime.

kotlinx-datetime is very early stage and not as actively developed as other official libraries. This library keeps adding missing pieces until the official library catches up.

Installation

build.gradle.kts:

dependencies {
	implementation("io.fluidsonic.time:fluid-time:0.14.0")
}

Additions

  • Duration(days, hours, minutes, seconds, nanoseconds)Duration factory function using components
  • Duration.parse()/.parseOrNull() - parse Duration from ISO-8601 string
  • DurationSerializer - kotlinx-serialization serializer for Duration
  • LocalDate.atTime(LocalTime): LocalDateTime - create LocalDateTime from LocalDate and LocalTime
  • LocalDateOrNull(year, month, day) - like LocalDate() but returns null instead of throwing
  • LocalDateTime.time - returns its time components as LocalTime
  • LocalTime - similar to the existing LocalDate and LocalDateTime
  • LocalTime.midnight - 00:00
  • LocalTime.atDate(LocalDate): LocalDateTime - create LocalDateTime from LocalDate and LocalTime
  • Timestamp - alias of Instant for those who prefer that name (Discussion)
  • (LocalDate|LocalDateTime|LocalTime|Timestamp).parseOrNull(String) - like parse() but returns null instead of throwing
  • TimeZone.ofOrNull(String) - like of() but returns null instead of throwing
  • Timestamp.durationSince(Timestamp)/.durationUntil(Timestamp) - get Duration between two timestamps
  • Timestamp.toLocalDate(TimeZone) - shortcut for .toLocalDateTime(timeZone).date
  • Timestamp.toLocalTime(TimeZone) - shortcut for .toLocalDateTime(timeZone).time
  • Timestamp.toJavaDate(): Date - converts a Timestamp to java.util.Date (JVM only)
  • Month.daysIn(year) - number of days in a given month and year
  • Year.isLeap(year) - whether a year is a leap year
  • ManualClock - a Clock implementation suitable for unit testing
  • JVM, JS and Darwin are supported. linuxX64 and mingwX64 are not supported.

Previous library

Before kotlinx-datetime was released this library has provided its own date & time implementations for JVM and Darwin. That work has been discontinued in favor of using the new official library, even if experimental, with additions provided by this reworked library. Bugfix releases will still be provided if needed.

You can still use the last previous library version 0.10.5.

License

Apache 2.0

You might also like...
Joda-Time library with Android specialization

Android has built-in date and time handling - why bother with a library? If you've worked with Java's Date and Calendar classes you can probably answer this question yourself, but if not, check out Joda-Time's list of benefits.

java.time Kotlin extension functions library.
java.time Kotlin extension functions library.

Java Time Kotlin extension functions. Background Java Time became integrated to the JDK as of Java 8. It was a huge improvement over its Date predeces

Estimated Time of Arrival Bar
Estimated Time of Arrival Bar

Estimated Time of Arrival Bar

Asimov-flagz-kt - Feature flags library based on Togglz library

Asimov Flagz Feature flags library based on Togglz library. Installation Gradle

Android library for better Picker DialogFragments
Android library for better Picker DialogFragments

DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numbers, and other things.

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

Android Week View Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling. Fea

An android library which provides a compact calendar view much like the one used in google calenders.
An android library which provides a compact calendar view much like the one used in google calenders.

CompactCalendarView CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar clas

CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour

CustomizableCalendar This library allows you to create a completely customizable calendar. You can use CustomizableCalendar to create your calendar, c

android library dialog month picker
android library dialog month picker

RackMonthPicker android library dialog month picker Download Download via Maven: Add the JitPack repository to your build file repositories rep

Comments
  • Add support for M1

    Add support for M1

    Kotlin 1.5.30 introduced support for more targets for Apple silicon. macosArm64, iosSimulatorArm64, watchosSimulatorArm64, and tvosSimulatorArm64

    Would it be possible to update the kotlin version to be able to use this library on the new target?

    To my understanding it would require you to update the kotlin version in the following gradle plugin: https://github.com/fluidsonic/fluid-gradle

    opened by JohNan 1
Releases(0.15.0)
  • 0.15.0(Jan 23, 2022)

    • Kotlin 1.6.10
    • kotlinx-datetime 0.3.2
    • kotlinx-serialization 1.3.2
    • Added watchosX64 and new arm64 Darwin targets
    • Deprecated Duration.parse(…) and Duration.parseNotNull(…)
    Source code(tar.gz)
    Source code(zip)
  • 0.14.0(May 27, 2021)

    • Kotlin 1.5.10 & kotlinx-datetime 0.2.0
    • Added Duration(days, hours, minutes, seconds, nanoseconds) factory function
    • Added Duration.parse(…)/.parseOrNull(…) (ISO 8601)
    • Added DurationSerializer
    • Added Timestamp.durationSince(…)/.durationUntil(…)
    • Added LocalTime.toJavaLocalTime()
    • Added LocalDateOrNull()
    • Made improvements to ManualClock (intended for unit testing)
    Source code(tar.gz)
    Source code(zip)
  • 0.13.1(Jan 21, 2021)

  • 0.12.0(Dec 18, 2020)

  • 0.10.5(Dec 15, 2020)

  • 0.10.4(Oct 25, 2020)

  • 0.10.0(Jul 29, 2020)

  • 0.9.15(Oct 19, 2019)

  • 0.9.14(Oct 18, 2019)

    • Renamed Duration to PreciseDuration to avoid conflict with kotlin.time.
    • Renamed Clock to WallClock to avoid conflict with kotlin.time.
    • Marked many functions as inline to reduce boxing.
    • Fixed several bugs.
    • Added unit testing for all measurement classes.
    Source code(tar.gz)
    Source code(zip)
Owner
Marc Knaup
❤️ @Kotlin, building things, breaking things, writing software, discovering crypto. Hell yes global citizens.
Marc Knaup
KotlinX multiplatform date/time library

kotlinx-datetime A multiplatform Kotlin library for working with date and time. See Using in your projects for the instructions how to setup a depende

Kotlin 1.6k Jan 5, 2023
Asimov-time-kt - Useful time and date related functions and extensions

asimov/time Useful time and date related functions and extensions. Installation

Nicolas Bottarini 1 Jan 7, 2022
Android NTP time library. Get the true current time impervious to device clock time changes

TrueTime for Android Make sure to check out our counterpart too: TrueTime, an NTP library for Swift. NTP client for Android. Calculate the date and ti

Instacart 1.3k Jan 4, 2023
Multiplatform Date and time library for Kotlin

Klock is a Date & Time library for Multiplatform Kotlin. It is designed to be as allocation-free as possible using Kotlin inline classes, to be consis

null 681 Dec 19, 2022
A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.

SublimePicker A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface. You can also view 'Su

Vikram 2.3k Jan 4, 2023
Pick a date or time on Android in style

Material DateTime Picker - Select a time/date in style Material DateTime Picker tries to offer you the date and time pickers as shown in the Material

null 4.7k Dec 29, 2022
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Square 4.4k Dec 20, 2022
Compose Date Picker - Select month and year

Android DatePicker with month and year build with Compose UI

Doğuş Teknoloji 47 Dec 15, 2022
A simple Cupcake Ordering App, choose flavor, pickup on a date, get order summary and send order via any other app.

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

Akshat Khandelwal 0 Dec 23, 2021
MinutesAliveApp - Basic Android App that ask for your date of birth and shows your age in minutes

MinutesAliveApp Basic Android App that ask for your date of birth and shows your

JestorDev 0 Jan 30, 2022