Difference between revisions of "DateTime class"

From Catglobe Wiki
Jump to: navigation, search
 
(2 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
|Name=<nowiki>DateTime</nowiki>
 
|Name=<nowiki>DateTime</nowiki>
 
|Description=<nowiki>The DateTime object</nowiki>
 
|Description=<nowiki>The DateTime object</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Description=<nowiki>Now in UTC timezone</nowiki>}}
 
{{CGscriptConstructors_Template|Description=<nowiki>Now in UTC timezone</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
Line 13: Line 13:
 
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>AsUnixtimeMillisecondsSince1970</nowiki>|Description=<nowiki>Return value as number of milliseconds since 1 / 1 1970</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>AsUnixtimeMillisecondsSince1970</nowiki>|Description=<nowiki>Return value as number of milliseconds since 1 / 1 1970</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>AsUnixtimeSecondsSince1970</nowiki>|Description=<nowiki>Return value as number of seconds since 1/1 1970</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>AsUnixtimeSecondsSince1970</nowiki>|Description=<nowiki>Return value as number of seconds since 1/1 1970</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>CompareTo</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to compare to</nowiki>}}
 +
|Description=<nowiki>Compare to object. See ArrayConstant.OrderBy</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
 
{{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>AsArray</nowiki>|HasGetter=1|Description=<nowiki>Return value as the array representation of a date</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>AsArray</nowiki>|HasGetter=1|Description=<nowiki>Return value as the array representation of a date</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
 
}}
 
}}
 
  
 
==== <span style="color:#a52a2a">'''Examples'''</span> ====
 
==== <span style="color:#a52a2a">'''Examples'''</span> ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 +
//*Ex1
 
DateTime dt = new DateTime ();
 
DateTime dt = new DateTime ();
 
print(dt.AsArray);//{2017,10,2,4,13,34,583,40,0}
 
print(dt.AsArray);//{2017,10,2,4,13,34,583,40,0}
 
+
//*Ex2
DateTime dt = new DateTime("2009/04/05");
+
DateTime dt = new DateTime("2009/4/5");
 
print(dt.ToString());//2009-04-05 00:00:00
 
print(dt.ToString());//2009-04-05 00:00:00
 
+
print(dt.AsArray);//{2009,4,5,0,0,0,0,14,0}
DateTime dt = new DateTime("2017/02/14");
+
//*Ex3
print(dt.AsArray);//{2017,2,14,0,0,0,0,7}
 
 
 
 
DateTime dt = new DateTime({2017,10,2,4,13,34,583,40,0});
 
DateTime dt = new DateTime({2017,10,2,4,13,34,583,40,0});
 
print(dt.ToString());//2017-10-02 04:13:34
 
print(dt.ToString());//2017-10-02 04:13:34

Latest revision as of 09:01, 2 July 2020

DateTime



The DateTime object

Parent class

Inherits from object

Constructors

  • () - Now in UTC timezone
  • (string value "Value to parse as a date, syntax is same as for constant values") - New based on a string representation of a date
  • (array value "Value to parse as a date") - New based on a array representation of a date

Methods

  • number AsUnixtimeMillisecondsSince1970() - Return value as number of milliseconds since 1 / 1 1970
  • number AsUnixtimeSecondsSince1970() - Return value as number of seconds since 1/1 1970
  • int CompareTo(DateTime value "Value to compare to") - Compare to object. See ArrayConstant.OrderBy
  • string ToString() - The string representation of the object.

Properties

  • array AsArray { get; } - Return value as the array representation of a date
  • string ObjectTypeName { get; } - The name of the type of object.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.


Examples

//*Ex1
DateTime dt = new DateTime ();
print(dt.AsArray);//{2017,10,2,4,13,34,583,40,0}
//*Ex2
DateTime dt = new DateTime("2009/4/5");
print(dt.ToString());//2009-04-05 00:00:00
print(dt.AsArray);//{2009,4,5,0,0,0,0,14,0}
//*Ex3
DateTime dt = new DateTime({2017,10,2,4,13,34,583,40,0});
print(dt.ToString());//2017-10-02 04:13:34
print(dt.AsUnixtimeMillisecondsSince1970());//1506917614583
print(dt.AsUnixtimeSecondsSince1970());//1506917614