[Reprint] ext core API explanation (2)-array/date/function/number/string

Source: Internet
Author: User
Tags format definition month name
Array class
Indexof (Object O): Number
Whether the object is in the array. If-1 is not found, the returned position is found.
Remove (Object O): Array
Deletes the specified object from the array. If the object cannot be found, the array does not change.

Number
Constrain (number min, number max): Number
Check whether the value is between min and max. If it is greater than Max, return Max. If it is less than min, return min; otherwise, return the current value.

String type
Escape (string): String
Replace 'and "in string "'""

Format (string, string value1, string value2): String
Format a string, for example:
VaR CLS = 'my-class', text = 'some text ';
VaR S = string. format ('<Div class = "{0}"> {1} </div>', CLS, text ); // result <Div class = "My-class"> some text </div>

Leftpad (string, number size, [String char]): String
Fill string with the size length in char. Char defines spaces by default.

Toggle (string value, string other): String
Exchange value. If the current value is equal to value, other is assigned, and vice versa. For example:
Sort = sort. Toggle ('asc ', 'desc ');

Trim (): String
Remove unnecessary spaces at the beginning or end

Date class
Date. parsedate (string input, string format): Date
Converts string to time according to the specified format. For the format definition, see the format method.
Example: dt = date. parsedate ("3:20:01", "Y-m-d h: I: S ");

Add (string interval, number value): Date
Added time period. String interval is defined in the data class.
Date. Milli = "Ms ";
Date. Second = "S ";
Date. Minute = "mi ";
Date. Hour = "H ";
Date. Day = "D ";
Date. month = "Mo ";
Date. Year = "Y ";
For example, VAR dt2 = new date ('2014/1/123'). Add (date. Day,-5 );

Between (date start, date end): Boolean
Whether it is between two specified times

Cleartime (Boolean clone): Date
Clear the time information. If clone is true, clone yourself and return the new date. The value of the new date does not change. Otherwise, modify the value of the new date.

Clone (): Date
Clone

Format (string format): String
Formatting time
D double-digit date 01 to 31
D. Name of the week from Mon to Sun
J. One-digit date 1 to 31
L complete week names from Sunday to Saturday
The end of the s date in English order. It contains two characters: St, Nd, RD or th.
W. day of the week 0 (Sunday) to 6 (Saturday)
The day of a year in Z: 0 to 364 (leap year 365)
W ISO-8601 the number of weeks, Monday is the beginning of a week 1 to 53
Full English names of month F: January to December
M month, with 0 leading 01 to 12
The month name can be abbreviated as Jan to Dec.
N months 1 to 12
T how many days are there this month, 28 to 31?
L whether the leap year is 1/0
Y complete year example: 1999 or 2003
The last two examples of Y: 99 or 03
A: AM/PM in lower case
A: uppercase am or PM in the morning/afternoon
G hour/12 hour in the format of 1 to 12
G hour/24 hour: 0 to 23
H hour/12 hour system 01 to 12
H-hour/24-hour 00 to 23
I minute 00 to 59
S seconds 00 to 59
U, 001 to 999 milliseconds
O time zone, which is different from Greenwich Mean Time (GMT). Example: + 0200
Abbreviation of t time zone: est, MDT...
Z Time Zone spacing-43200 to 50400
The date class has several built-in formats.
Date. Patterns = {
Iso8601long: "Y-m-d h: I: s ",
Iso8601short: "Y-m-d ",
Expiry date: "N/J/Y ",
Longdate: "l, f d, Y ",
Fulldatetime: "l, f d, y g: I: s ",
Monthday: "f d ",
Processing time: "G: I ",
Longtime: "G: I: s ",
Sortabledatetime: "Y-m-d" "TH: I: s ",
Universalsortabledatetime: "Y-m-d h: I: So ",
Yearmonth: "f, Y"
};
Of course, iso8601long and iso8601short are very attractive.
Example:
DT. Format (date. patterns. iso8601long );
DT. Format ('Y-m-d h: I: s ');
 
Getdayofyear (): Number
The day of the year, starting from 0

Getdaysinmonth (): Number
How many days are there in this month,

Getelapsed ([date]): Number
Number of milliseconds between the current date object and date

Getfirstdateofmonth (): Date
The first day of this month

Getfirstdayofmonth (): Number
The first day of this month is the day of the week

Getgmtoffset (): String
Time zone information (see 'O' in the format definition ')
Getfirstdateofmonth (): Date
Last day of this month
 
Getfirstdayofmonth (): Number
The last day of this month is the day of the week.

Getsuffix (): String
After-date guide (see "S" in the format definition)

Gettimezone (): String
Time zone (see T)

Getweekofyear (): Number
Week of the year (see W)

Isleapyear (): Boolean
Leap year

Function class
Createcallback (/* ARGs... */): Function
Create call back method

Createdelegate ([object OBJ], [array ARGs], [Boolean/number appendargs]):
Create Delegation
Apart from passing parameters, the two methods do not show any difference. They call method. Apply. createcallback can be considered as a simplified version of createdelegate.
Createcallback ==> return method. Apply (window, argS );
Createdelegate ==> return method. Apply (OBJ | window, callargs );
The former parameter is relatively simple and passed directly. The latter rule is more complex. If appendargs is true, argS will be appended to the parameter list. If it is a value, ARGs is inserted at the appendargs position in the parameter list. In other cases, the original parameter does not work.
Example:
VaR fn = func1.createdelegate (scope, [arg1, arg2], true)
// FN (a, B, c) = scope. func1 (a, B, c, arg1, arg2 );
VaR fn = func1.createdelegate (scope, [arg1, arg2])
// FN (a, B, c) === scope. func1 (arg1, arg2 );
VaR fn = func1.createdelegate (scope, [arg1, arg2], 1)
// FN (a, B, c) = scope. func1 (A, arg1, arg2, B, c );
VaR fn = func1.createcallback (arg1, arg2 );
// FN () = func1 (arg1, arg2)

Createcallback: function (/* ARGs ...*/)

Createinterceptor (function FCN, [object scope]): Function
Create a blocking method. If FCN returns false, the original method will not be executed.

Createsequence (function FCN, [object scope]): Function
Create a combination method and execute the original method + FCN

Defer (number millis, [object OBJ], [array ARGs], [Boolean/number appendargs]): Number
Scheduled execution. The original method is executed after millis milliseconds.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.