Time structure

Introduced properties

init gmtime: Tm

core :: Tm :: gmtime

Create a new Time structure expressed in Coordinated Universal Time (UTC).
init gmtime_from_timet(t: TimeT): Tm

core :: Tm :: gmtime_from_timet

Create a new Time structure expressed in UTC from t.
fun hour: Int

core :: Tm :: hour

hours since midnight.
fun is_dst: Bool

core :: Tm :: is_dst

Is self in Daylight Saving Time.
init localtime: Tm

core :: Tm :: localtime

Create a new Time structure expressed in the local timezone.
init localtime_from_timet(t: TimeT): Tm

core :: Tm :: localtime_from_timet

Create a new Time structure expressed in the local timezone from t.
fun mday: Int

core :: Tm :: mday

Day of the month.
fun min: Int

core :: Tm :: min

Minutes after the hour.
fun mon: Int

core :: Tm :: mon

Months since January.
fun sec: Int

core :: Tm :: sec

Seconds after the minute.
fun strftime(format: String): String

core :: Tm :: strftime

Convert self to a human readable String corresponding to format.
fun to_timet: TimeT

core :: Tm :: to_timet

Convert self as a TimeT.
fun wday: Int

core :: Tm :: wday

Days since Sunday.
fun yday: Int

core :: Tm :: yday

Days since January 1st.
fun year: Int

core :: Tm :: year

Years since 1900.

Redefined properties

redef type SELF: Tm

core $ Tm :: SELF

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

core $ Tm :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun address_is_null: Bool

core :: Pointer :: address_is_null

Is the address behind this Object at NULL?
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 free

core :: Pointer :: free

Free the memory pointed by this pointer
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
init gmtime: Tm

core :: Tm :: gmtime

Create a new Time structure expressed in Coordinated Universal Time (UTC).
init gmtime_from_timet(t: TimeT): Tm

core :: Tm :: gmtime_from_timet

Create a new Time structure expressed in UTC from t.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun hour: Int

core :: Tm :: hour

hours since midnight.
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_dst: Bool

core :: Tm :: is_dst

Is self in Daylight Saving Time.
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.
init localtime: Tm

core :: Tm :: localtime

Create a new Time structure expressed in the local timezone.
init localtime_from_timet(t: TimeT): Tm

core :: Tm :: localtime_from_timet

Create a new Time structure expressed in the local timezone from t.
fun mday: Int

core :: Tm :: mday

Day of the month.
fun min: Int

core :: Tm :: min

Minutes after the hour.
fun mon: Int

core :: Tm :: mon

Months since January.
init nul: Pointer

core :: Pointer :: nul

C NULL pointer
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 sec: Int

core :: Tm :: sec

Seconds after the minute.
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun strftime(format: String): String

core :: Tm :: strftime

Convert self to a human readable String corresponding to format.
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun to_timet: TimeT

core :: Tm :: to_timet

Convert self as a TimeT.
fun wday: Int

core :: Tm :: wday

Days since Sunday.
fun yday: Int

core :: Tm :: yday

Days since January 1st.
fun year: Int

core :: Tm :: year

Years since 1900.
package_diagram core::Tm Tm core::Pointer Pointer core::Tm->core::Pointer core::Object Object core::Pointer->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

extern class Pointer

core :: Pointer

Pointer classes are used to manipulate extern C structures.

Class definitions

core $ Tm
# Time structure
extern class Tm `{struct tm *`}

	# Create a new Time structure expressed in Coordinated Universal Time (UTC).
	new gmtime `{
		struct tm *tm;
		time_t t = time(NULL);
		tm = gmtime(&t);
		return tm;
	`}

	# Create a new Time structure expressed in UTC from `t`.
	new gmtime_from_timet(t: TimeT) `{
		struct tm *tm;
		tm = gmtime(&t);
		return tm;
	`}

	# Create a new Time structure expressed in the local timezone.
	new localtime `{
		struct tm *tm;
		time_t t = time(NULL);
		tm = localtime(&t);
		return tm;
	`}

	# Create a new Time structure expressed in the local timezone from `t`.
	new localtime_from_timet(t: TimeT) `{
		struct tm *tm;
		tm = localtime(&t);
		return tm;
	`}

	# Convert `self` as a TimeT.
	fun to_timet: TimeT `{ return mktime(self); `}

	# Seconds after the minute.
	fun sec: Int `{ return self->tm_sec; `}

	# Minutes after the hour.
	fun min: Int `{ return self->tm_min; `}

	# hours since midnight.
	fun hour: Int `{ return self->tm_hour; `}

	# Day of the month.
	fun mday: Int `{ return self->tm_mday; `}

	# Months since January.
	fun mon: Int `{ return self->tm_mon; `}

	# Years since 1900.
	fun year: Int `{ return self->tm_year; `}

	# Days since Sunday.
	fun wday: Int `{ return self->tm_wday; `}

	# Days since January 1st.
	fun yday: Int `{ return self->tm_yday; `}

	# Is `self` in Daylight Saving Time.
	fun is_dst: Bool `{ return self->tm_isdst; `}

	# Convert `self` to a human readable String.
	private fun asctime: CString `{ return asctime(self); `}

	# Convert `self` to a human readable String corresponding to `format`.
	# TODO document allowed format.
	fun strftime(format: String): String import String.to_cstring, CString.to_s `{
		char* buf, *c_format;

		buf = (char*)malloc(100);
		c_format = String_to_cstring(format);

		strftime(buf, 100, c_format, self);
		String s = CString_to_s(buf);
		free(buf);
		return s;
	`}

	redef fun to_s do return asctime.to_s.replace("\n", "")
end
lib/core/time.nit:100,1--181,3