A Time in a Date

Introduced properties

init defaultinit(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int)

date :: DateTime :: defaultinit

init now

date :: DateTime :: now

Get the current DateTime

Redefined properties

redef fun ==(other: nullable Object): Bool

date $ DateTime :: ==

Have self and other the same value?
redef type OTHER: DateTime

date $ DateTime :: OTHER

What self can be compared to?
redef type SELF: DateTime

date $ DateTime :: SELF

Type of this instance, automatically specialized in every class
redef fun to_s: String

date $ DateTime :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
abstract fun <(other: OTHER): Bool

core :: Comparable :: <

Is self lesser than other?
fun <=(other: OTHER): Bool

core :: Comparable :: <=

not other < self
fun <=>(other: OTHER): Int

core :: Comparable :: <=>

-1 if <, +1 if > and 0 otherwise
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
fun >(other: OTHER): Bool

core :: Comparable :: >

other < self
fun >=(other: OTHER): Bool

core :: Comparable :: >=

not self < other
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type OTHER: Comparable

core :: Comparable :: OTHER

What self can be compared to?
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun clamp(min: OTHER, max: OTHER): OTHER

core :: Comparable :: clamp

Constraint self within [min..max]
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun day: Int

date :: Date :: day

Day of the month
protected fun day=(day: Int)

date :: Date :: day=

Day of the month
init defaultinit(hour: Int, minute: Int, second: Int)

date :: Time :: defaultinit

init defaultinit(year: Int, month: Int, day: Int)

date :: Date :: defaultinit

init defaultinit(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int)

date :: DateTime :: defaultinit

fun diff_days(other: Date): Int

date :: Date :: diff_days

Difference in days between self and other
fun diff_months(other: Date): Int

date :: Date :: diff_months

Difference in months between self and other
fun diff_time(other: Time): Int

date :: Time :: diff_time

Get the difference between two times in second
fun diff_years(other: Date): Int

date :: Date :: diff_years

Difference in years between self and other
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun hour: Int

date :: Time :: hour

The hour part of this time, between 0 and 23
protected fun hour=(hour: Int)

date :: Time :: hour=

The hour part of this time, between 0 and 23
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_between(c: OTHER, d: OTHER): Bool

core :: Comparable :: is_between

c <= self <= d
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun max(other: OTHER): OTHER

core :: Comparable :: max

The maximum between self and other (prefers self if equals).
fun min(c: OTHER): OTHER

core :: Comparable :: min

The minimum between self and c (prefer self if equals)
fun minute: Int

date :: Time :: minute

The minute within the hour, between 0 and 59
protected fun minute=(minute: Int)

date :: Time :: minute=

The minute within the hour, between 0 and 59
fun month: Int

date :: Date :: month

Month as an integer, 1 for January, 2 for February, etc.
protected fun month=(month: Int)

date :: Date :: month=

Month as an integer, 1 for January, 2 for February, etc.
init now

date :: DateTime :: now

Get the current DateTime
init now

date :: Time :: now

Get the current time of the day
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun second: Int

date :: Time :: second

The second within the minute, between 0 and 59
protected fun second=(second: Int)

date :: Time :: second=

The second within the minute, between 0 and 59
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun time_zone: String

date :: Date :: time_zone

UTC time zone
protected fun time_zone=(time_zone: String)

date :: Date :: time_zone=

UTC time zone
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
init today

date :: Date :: today

The date of this day
fun year: Int

date :: Date :: year

Year, ex: 1989
protected fun year=(year: Int)

date :: Date :: year=

Year, ex: 1989
package_diagram date::DateTime DateTime date::Date Date date::DateTime->date::Date date::Time Time date::DateTime->date::Time core::Comparable Comparable date::Date->core::Comparable date::Time->core::Comparable ...core::Comparable ... ...core::Comparable->core::Comparable

Ancestors

interface Comparable

core :: Comparable

The ancestor of class where objects are in a total order.
interface Object

core :: Object

The root of the class hierarchy.

Parents

class Date

date :: Date

A date, composed by a year, a month and a day
class Time

date :: Time

A time of the day, composed of an hour, a minute and a second count

Class definitions

date $ DateTime
# A `Time` in a `Date`
class DateTime
	super Date
	super Time
	redef type OTHER: DateTime
	autoinit year, month, day, hour, minute, second

	# Get the current `DateTime`
	init now
	do
		super
		today
	end

	redef fun ==(other) do return other isa DateTime and diff_days(other) == 0 and time_eq(other)

	redef fun to_s do return "{super} {hour}:{minute}:{second}{time_zone}"
end
lib/date/date.nit:159,1--176,3