Package-level declarations

Types

Link copied to clipboard

DateLimitation is an enum class for limitation TimeAgo prefix and suffix.

Link copied to clipboard
object TimeAgo

TimeAgo is an Object that converts a date into a humanized text. Instead of showing a date 2020-12-12 18:30 with timeago you can display something like "now", "an hour ago", "~1y", etc

Properties

Link copied to clipboard
val Double.months: Duration

Returns a Duration equal to this Double number of months.

val Int.months: Duration

Returns a Duration equal to this Int number of months.

val Long.months: Duration

Returns a Duration equal to this Long number of months.

Link copied to clipboard
val Double.weeks: Duration

Returns a Duration equal to this Double number of weeks.

val Int.weeks: Duration

Returns a Duration equal to this Int number of weeks.

val Long.weeks: Duration

Returns a Duration equal to this Long number of weeks.

Link copied to clipboard
val Double.years: Duration

Returns a Duration equal to this Double number of years.

val Int.years: Duration

Returns a Duration equal to this Int number of years.

val Long.years: Duration

Returns a Duration equal to this Long number of years.

Functions

Link copied to clipboard
fun now(): Instant

Get current time in Instant.

Link copied to clipboard

Get current time in Calendar format.

Link copied to clipboard

Get current Date.

Link copied to clipboard
fun nowInLocalDate(timeZone: TimeZone = TimeZone.currentSystemDefault()): LocalDate

Get current LocalDate.

Link copied to clipboard
fun nowInLocalDateTime(timeZone: TimeZone = TimeZone.currentSystemDefault()): LocalDateTime

Get current LocalDateTime.

Link copied to clipboard
fun nowInLocalTime(timeZone: TimeZone = TimeZone.currentSystemDefault()): LocalTime

Get current LocalTime.

Link copied to clipboard
fun nowInMilliseconds(): Long

Get current time in milliseconds.

Link copied to clipboard
fun Calendar.timeAgo(locale: String = TimeAgo.default, clock: Calendar = nowInCalendar(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String
fun Date.timeAgo(locale: String = TimeAgo.default, clock: Date = nowInDate(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String
fun Long.timeAgo(locale: String = TimeAgo.default, clock: Long = nowInMilliseconds(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String
fun Instant.timeAgo(locale: String = TimeAgo.default, clock: Instant = now(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String
fun LocalDateTime.timeAgo(locale: String = TimeAgo.default, clock: LocalDateTime = nowInLocalDateTime(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided this value to a fuzzy time like 'a moment ago'.