All Projects → pishen → minitime

pishen / minitime

Licence: Apache-2.0 license
Minitime - a Java Time wrapper for Scala and Scala.js

Programming Languages

scala
5932 projects

Labels

Projects that are alternatives of or similar to minitime

Travel
Framework agnostic PHP package to control the time.
Stars: ✭ 251 (+1468.75%)
Mutual labels:  time
perfy
A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.
Stars: ✭ 54 (+237.5%)
Mutual labels:  time
timechange
Efficient Updating of Date-Times
Stars: ✭ 25 (+56.25%)
Mutual labels:  time
nativescript-datetimepicker
Plugin with date and time picking fields
Stars: ✭ 26 (+62.5%)
Mutual labels:  time
iso8601
A fast ISO8601 date parser for Go
Stars: ✭ 122 (+662.5%)
Mutual labels:  time
crystime
Advanced time, calendar, schedule, and remind library for Crystal
Stars: ✭ 23 (+43.75%)
Mutual labels:  time
Jiffy
Jiffy is a Flutter (Android, IOS and Web) date time package inspired by momentjs for parsing, manipulating, querying and formatting dates
Stars: ✭ 238 (+1387.5%)
Mutual labels:  time
ESP32Time
An Arduino library for setting and retrieving internal RTC time on ESP32 boards
Stars: ✭ 120 (+650%)
Mutual labels:  time
jodaTime
Format and Parse date and time with joda layout
Stars: ✭ 67 (+318.75%)
Mutual labels:  time
ngx-mat-timepicker
A true material timepicker
Stars: ✭ 45 (+181.25%)
Mutual labels:  time
ptera
Ptera is DateTime library for Deno
Stars: ✭ 62 (+287.5%)
Mutual labels:  time
QuickTraceiOSLogger
A real time iOS log trace tool, view iOS log with pc web browser under local area network, which will automatically scroll like xcode. 一个实时的iOS日志跟踪工具,在局域网中使用 PC Web 浏览器查看 iOS 日志,它将像xcode一样自动滚动。
Stars: ✭ 16 (+0%)
Mutual labels:  time
easyappointments-integrations
📅 Various platform integration packages of Easy!Appointments
Stars: ✭ 29 (+81.25%)
Mutual labels:  time
Prayer Times Android Azan
Prayer + Time + Android + Kotlin + Azan + Library + timezone + islamic + salah + Library aiming to calculate prayer time with one line code , if you implement prayer time application , there is no need to do this headache again .
Stars: ✭ 251 (+1468.75%)
Mutual labels:  time
gostrftime
strftime for Go
Stars: ✭ 21 (+31.25%)
Mutual labels:  time
Server
self-hosted tag-based time tracking
Stars: ✭ 238 (+1387.5%)
Mutual labels:  time
ardusamber
Desamber time Arduino corporealization
Stars: ✭ 20 (+25%)
Mutual labels:  time
date-extractor
Extract dates from text
Stars: ✭ 58 (+262.5%)
Mutual labels:  time
HorizontalTimesLayout
Layout to display time slots in horizontal 24 hour format
Stars: ✭ 31 (+93.75%)
Mutual labels:  time
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+106.25%)
Mutual labels:  time

Minitime

Build Status

A Scala/Scala.js library which lets you operate on time and dates easily using +, -, *, /, >, <, to, sortBy, and more.

This library is a Scala wrapper around Java 8 Time API, with Scala.js implementation supported by scala-java-time.

Inspired by time for scala and chronoscala, I tried to provide additional features like time range (t1 to t2 by 3.hours) and Ordering typeclasses.

Installation

libraryDependencies += "net.pishen" %% "minitime" % "0.3.0"

// for Scala.js
libraryDependencies += "net.pishen" %%% "minitime" % "0.3.0"

Instantiation

import minitime._

val ld1 = LocalDate.now
val ld2 = LocalDate(2007, 8, 31)
val ld3 = LocalDate.parse("2018-03-09")

val ldt = LocalDateTime(2016, 7, 30, 19, 30, nano = 30000)

val lt = LocalTime.parse("12:35")

val zdt = ZonedDateTime.parse("2012-01-27T00:00:00.000000+09:00")

val d1: Duration = 1.hour
val d2: Duration = 2.minutes
val d3: Duration = 3.millis
val d4: Duration = Duration.parse("PT3S")

val p1: Period = 1.day
val p2: Period = 2.weeks
val p3: Period = 3.months
val p4: Period = Period(years = 1, months = 2, days = 3)

Basic Arithmetic

LocalDate(2018, 1, 31) + 1.day * 2
// 2018-02-02

LocalDate(2018, 4, 30) - 2.month
// 2018-02-28

LocalDateTime(2018, 8, 31, 23, 59) + 1.minute + 3.seconds
// 2018-09-01T00:00:03

LocalDate(2018, 3, 1) - LocalDate(2018, 2, 1)
// P28D

LocalDateTime.parse("2018-09-01T15:39:39") - LocalDateTime(2018, 8, 31, 0, 0)
// java.time.Duration = PT39H39M39S

3.minutes / 2 + 3.seconds * 3
// java.time.Duration = PT1M39S

Ordering

3.minutes < 3.hours
// true

LocalDate(2018, 3, 9) <= LocalDate(2017, 8, 31)
// false

Seq(1.hour, 2.minutes, 3.seconds).sorted
// List(PT3S, PT2M, PT1H)

Set(LocalDate(2018, 8, 29), LocalDate(2018, 8, 30), LocalDate(2018, 8, 31)).max
// 2018-08-31

Note that Ordering.Implicits.infixOrderingOps is automatically imported to make the operations >, <, >=, <=, max, min available. If you don't want this feature or you met some ambiguous implicit conversions, remove the auto import using import minitime.{infixOrderingOps => _, _}.

TimeRange

LocalDate.parse("2018-01-01") to LocalDate.parse("2018-01-05")
// TimeRange(2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05)

LocalDate.parse("2018-01-01") till LocalDate.parse("2018-01-05")
// TimeRange(2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04)

LocalDate.parse("2018-01-01") to LocalDate.parse("2018-01-05") by 2.days
// TimeRange(2018-01-01, 2018-01-03, 2018-01-05)

LocalDate.parse("2018-01-31") to LocalDate.parse("2018-05-01") by 1.month
// TimeRange(2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30)

LocalDateTime.parse("2018-01-01T00:00:00") till LocalDateTime.parse("2018-01-01T00:00:03")
// TimeRange(2018-01-01T00:00, 2018-01-01T00:00:01, 2018-01-01T00:00:02)

LocalDateTime.parse("2018-01-01T00:00") to LocalDateTime.parse("2018-01-01T06:00") by 2.hour
// TimeRange(2018-01-01T00:00, 2018-01-01T02:00, 2018-01-01T04:00, 2018-01-01T06:00)

TimeRange[T] extends Seq[T], with a constant time apply() and linear time length().

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].