HDateTime
Description
Auxiliary class for time handling.Inherits from:
Implemented by:
Constructor Method
The constructor is invoked, when a new instance of HDateTime is created.
To create a new instance use HDateTime.nu( ) or new HDateTime( ).
constructor( )
Inherited from: HClass
Protected instance method, gets called when a new instance is created.
Class Methods
implement( interface )
Inherited from: HClass
Description
Copies the members of interface to a HClass or a class inherited from HClass.Usage:
Defines an interface:// Create an interface class that calculates the area var AreaInterface = HClass.extend({ constructor: null, area: function() { return this.getWidth() * this.getHeight(); } });// Create a class that contains the coordinates of a rectangle. var Rectangle = HClass.extend({ constructor: function( x, y, width, height ) { this.x = x; this.y = y; this.width = width; this.height = height; }, getWidth: function() { return this.width; }, getHeight: function() { return this.height; } });
// Makes the Rectangle class implement the AreaInterface Rectangle.implement( AreaInterface );
nu( )
Inherited from: HClass
Class members:
Description
nu is a protected class method.
It does the same thing as the new keyword, but it is a class method.
Parameters:
Any parameters are passed on to theconstructor method.
Usage:
Creates a classMyClass, then creates two instances of it:
myClassInstance1 and myClassInstance2. The end result is the same.
var MyClass = HClass.extend({ name: 'Foo', constructor: function( param1, param2 ){ var logMsg = [ 'param1:', param1, 'param2:', param2, 'name:', this.name ]; console.log( logMsg.join(' ') ); } });
// Construction using the new keyword: var myClassInstance1 = new MyClass( 'one', 'two' );
// Construction using the nu method: var myClassInstance2 = MyClass.nu( 'one', 'two' );However, when extending in place, the benefits of the
nu method
become obvious.
// Extending in place with the new keyword: var myExtendedClassInstance1 = new ( MyClass.extend({ name: 'Bar' }) )( 'one', 'two' );
// The same as above, but using the nu method: var myExtendedClassInstance2 = MyClass.extend({ name: 'Bar' }).nu( 'one', 'two' );
extend( instance, static )
Inherited from: HClass
Description
The class method used to extend a class.If the member name constructor is defined as null instead of a function
block in the instance object block, the class is defined as a singleton
(single instance class).
Parameters:
instance |
The object that defines the class instance members. |
|---|---|
static |
The object that defines the static class members. |
Returns:
Returns the extended class object.Usage:
var Point = HClass.extend({ constructor: function( x, y ) { this.x = x; this.y = y; } }); var Rectangle = Point.extend({ // Instance members: constructor: function( x, y, width, height ) { this.base( x, y ); this.width = width; this.height = height; }, getWidth: function() { return this.width; }, getHeight: function() { return this.height; } }, // Class Members { description: "this is a Rectangle", getClass: function() { return this; } });
Instance Methods
monthName( date )
Description
Returns month name of the given date.Parameters
date |
Date to return month name from. |
|---|
Returns
Month nameweek( date )
Description
Returns week number for date given as input.Parameters
date |
Date to return week number from. |
|---|
Returns
Number of the week.month( date )
Description
Returns month number for the date given as input. Note that months are numbered from 0 to 11.Parameters
date |
Date to return month number from. |
|---|
Returns
Number of the month 0 (January) to 11 (December).firstDateOfMonth( date )
Description
Returns the first millisecond of the input given date's month.Parameters
date |
The date to get the first millisecond of the month |
|---|
Returns
The first millisecond on the given date's month as a Date object.firstDateOfWeek( date )
Description
Returns the first millisecond when the week starts for date given as input.Parameters
date |
The date to get the first millisecond. |
|---|
Returns
Date for the first millisecond of the week.tzMs( date )
Description
Returns the timezone offset in milliseconds.Parameters
date |
The date to get timezone offset from. |
|---|
Returns
Timezone offset in milliseconds.mday( date )
Description
Returns day of the month for the date given as input.Parameters
date |
Date to return day of the month. |
|---|
Returns
Day of the monthdate( epoch_seconds )
Description
Returns a Date instance for epoch given in seconds.Parameters
epoch_seconds |
Point of time given in seconds since 1 January 1970 00:00:00 UTC. |
|---|
Returns
Date objectlastDateOfYear( date )
Description
Get last millisecond of the input given date's year as a Date object.Parameters
date |
The last millisecond of the year on the date given. |
|---|
Returns
Last millisecond of the year as a Date object.lastDateOfWeek( date )
Description
Returns the last millisecond of the week for the given date.Parameters
date |
The date to get the last millisecond |
|---|
Returns
The last millisecond of the week as a Date object.year( date )
Description
Returns year for given date.Parameters
date |
Date to return year from. |
|---|
Returns
YearlastDateOfMonth( date )
Description
Returns the last millisecond of the input given date's month.Parameters
date |
The date to get the last millisecond of the month. |
|---|
Returns
The last millisecond of the given date's month as a Date object.firstDateOfYear( date )
Description
Returns a Date object with first millisecond of the year.Parameters
date |
The date to get the first millisecond of the same year. |
|---|
Returns
The Date object for the first millisecond of the yeartoString( )
Inherited from: HClass
Protected instance method, returns the instance represented as a String.
valueOf( )
Inherited from: HClass
Protected instance method, returns the value of an instance.
base( )
Inherited from: HClass
This method can be called from any other method to invoke that method's parent
Other Instance Members
msHour = 3600000
msDay = 86400000
msMinute = 60000
months_localized = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]
msWeek = 604800000
prototype = { }
Inherited from: Object
Description
Theprototype member of Object defines the instance members.
These are copied to the instance object when the new keyword is called.