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.timezone |
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:
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 Code shared systemTime systemTime Gets a clock that obtains the current instant using the best available system clock. |
zero | Source Code shared Period zero A period of zero length. |
Functions | |
date | Source Code Returns a date based on the specified year, month and day of month values. |
dateTime | Source Code shared 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. |
fixedTime | Source Code Gets a clock that always returns the same instant in the UTC time-zone. |
now | Source Code Obtains the current instant from the system clock. |
offsetTime | Source Code Returns an implementation of a clock that always returns a constant offset from the value of the provided clock. |
time | Source Code Creates new instance of Time. Parameters:
|
today | Source Code Returns current date according to the provided system clock and time zone. |
Interfaces | |
Clock | Source Code shared 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 Clock into any method that requires it. A dependency injection framework is one way to achieve this. This approach allows an alternate clock, such as fixedTime to be used during testing. The systemTime top level factory method offers clocks based on the best available
system clock, such as |
Date | Source Code shared 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 Code shared 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 Code shared 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”. |
Classes | |
DateRange | Source Code shared DateRange Implementation of Range and allows easy iteration between Date types. Provides all power of Iterable features and complements with:
|
DateTimeRange | Source Code shared DateTimeRange Implementation of Range and allows easy iteration between DateTime types. Provides all power of Iterable features and complements with:
|
Duration | Source Code shared Duration Duration specifies a discreet amount of milliseconds between two instances of time. |
Instant | Source Code shared 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 Code shared 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 Code shared TimeRange Implementation of Range and allows easy iteration between Time types. Provides all power of Iterable features and complements with:
|
systemTime | Source Code shared systemTime Gets a clock that obtains the current instant using the best available system clock. |