Date and Time library for Ceylon language SDK.
This library is loosely modeled/inspired by the JodaTime/JSR-310 date/time library.
Packages | |
ceylon.time | Main package for the Ceylon's Date and Time library. |
ceylon.time.base | Base classes and interfaces of the Date/Time library. |
ceylon.time.chronology | Package containing supported chronologies in ceylon.time library. |
ceylon.time.internal | |
ceylon.time.internal.math | |
ceylon.time.iso8601 | This package contains parsers implementations for reading |
ceylon.time.timezone | |
ceylon.time.timezone.model | All the models are intended to be unrelated of the database origin. |
ceylon.time.timezone.parser.iana |
Main package for the Ceylon's Date and Time library.
Like in JodaTime and JSR-310, there is a machine timeline and a human timeline.
Machine timeline is represented by an Instant
that is basically just an object
wrapper around an Integer
representing Unix time value. A value of an Instant
uniquely identifies a particular instant of time without needing to take into account
timezone information and contain no ambiguities associated with DST changeover times.
Human timeline is based mostly on Gregorian and ISO-8601 calendar systems and consists of the following principal data types:
Date
– A date value without time component.Time
– A time of day vallue without date component.DateTime
– A particular time of a particular date.ZoneDateTime
– A particular moment of time identified by date, time of day and
a time zone.Note: At the moment, timezone is not fully supported, therefore current
conversions can uses offsets provided by VMs and provides some features like timeZone
object that allows parser and creation of fixed offsets.
Values | |
systemTime | Source Codeshared systemTime systemTime Gets a clock that obtains the current instant using the best available system clock. |
zero | Source Codeshared Period zero A period of zero length. |
Functions | |
date | Source Codeshared Date date(Integer year, Integer|Month month, Integer day) Returns a date based on the specified year, month and day of month values. |
dateTime | Source Codeshared DateTime dateTime(Integer year, Integer|Month month, Integer day, Integer hours = 0, Integer minutes = 0, Integer seconds = 0, Integer milliseconds = 0) Returns a date based on the specified year, month and day of month values. Parameters:
|
fixedTime | Source Codeshared Clock fixedTime(Instant|Integer instant) Gets a clock that always returns the same instant in the UTC time-zone. |
now | Source Codeshared Instant now(Clock? clock = null) Obtains the current instant from the system clock. Parameters:
|
offsetTime | Source Codeshared Clock offsetTime(Clock baseClock, Duration offset) Returns an implementation of a clock that always returns a constant offset from the value of the provided clock. |
time | Source Codeshared Time time(Integer hours, Integer minutes, Integer seconds = 0, Integer milliseconds = 0) Creates new instance of Parameters:
|
today | Source Codeshared Date today(Clock clock = ..., TimeZone timeZone = ...) Returns current date according to the provided system clock and time zone. Parameters:
|
yearMonth | Source Codeshared YearMonth yearMonth(Integer year, Integer|Month month) Returns a year and month representation based on the specified values. |
Interfaces | |
Clock | Source Codeshared Clock A clock providing access to the current instant, date and time using a time-zone. Instances of this class are used to find the current instant, which can be
interpreted using the stored time-zone to find the current date and time.
As such, a clock can be used instead of The primary purpose of this abstraction is to allow alternate clocks to be plugged in as and when required. Applications use an object to obtain the current time rather than a static method. This can simplify testing. Applications should avoid using the top level objects directly.
Instead, they should pass a This approach allows an alternate clock, such as The |
Date | Source Codeshared Date An interface for date objects in the ISO-8601 calendar system. A date is often viewed as triple of year-month-day values. This interface also defines access to other date fields such as day-of-year, day-of-week and week-of-year. |
DateTime | Source Codeshared DateTime An abstract moment in time (like 4pm, October 21. 2012). DateTime does not contain a time zone information, so You can not use it to record or schedule events. |
Time | Source Codeshared Time Time of day like 6pm or 8.30am. This type contains only information about an abstract time of day without referencing any date or timezone. You use Time to specify something that has to occur on a specific time of day like “lunch hour starts at 1pm” or “shop opens at 10am”. |
YearMonth | Source Codeshared YearMonth An interface for year and month objects representation in the ISO-8601 calendar system. A YearMonth is often viewed as pair of year-month values. |
Classes | |
DateRange | Source Codeshared DateRange Implementation of Provides all power of
|
DateTimeRange | Source Codeshared DateTimeRange Implementation of Provides all power of
|
Duration | Source Codeshared Duration Duration specifies a discreet amount of milliseconds between two instances of time. |
Instant | Source Codeshared Instant A specific instant of time on a continuous time-scale. An instant represents a single point in time irrespective of any time-zone offsets or geographical locations. |
Period | Source Codeshared Period An immutable period consisting of the ISO-8601 years, months, days, hours, minutes, seconds and milliseconds, such as '3 Months, 4 Days and 7 Hours'. A period is a human-scale description of an amount of time. |
TimeRange | Source Codeshared TimeRange Implementation of Provides all power of
|
systemTime | Source Codeshared systemTime Gets a clock that obtains the current instant using the best available system clock. |