date.js
来自「Browser independent JavaScript SDK. Clas」· JavaScript 代码 · 共 572 行 · 第 1/2 页
JS
572 行
/** @ignore */
instance _$getUTCMinutes$_(){throw "don't call me, used for reflection.";}
/**
* Set the minutes in a Date object according to universal time (from 0-59).
* @name setUTCMinutes
* @param {Number} _minutes
* @memberof Date
* @function
*/
/** @ignore */
instance _$setUTCMinutes$_(_minutes){throw "don't call me, used for reflection.";}
/**
* Returns the seconds of a Date object (from 0-59).
* @name getSeconds
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getSeconds$_(){throw "don't call me, used for reflection.";}
/**
* Sets the seconds in a Date object (from 0-59).
* @name setSeconds
* @param {Number} _seconds
* @memberof Date
* @function
*/
/** @ignore */
instance _$setSeconds$_(_seconds){throw "don't call me, used for reflection.";}
/**
* Returns the seconds of a Date object according to universal time (from 0-59).
* @name getUTCSeconds
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getUTCSeconds$_(){throw "don't call me, used for reflection.";}
/**
* Set the seconds in a Date object according to universal time (from 0-59).
* @name setUTCSeconds
* @param {Number} _seconds
* @memberof Date
* @function
*/
/** @ignore */
instance _$setUTCSeconds$_(_seconds){throw "don't call me, used for reflection.";}
/**
* Returns the milliseconds of a Date object (from 0-999).
* @name getMilliseconds
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getMilliseconds$_(){throw "don't call me, used for reflection.";}
/**
* Sets the milliseconds in a Date object (from 0-999).
* @name setMilliseconds
* @param {Number} _milliseconds
* @memberof Date
* @function
*/
/** @ignore */
instance _$setMilliseconds$_(_milliseconds){throw "don't call me, used for reflection.";}
/**
* Returns the milliseconds of a Date object according to universal time (from 0-999).
* @name getUTCMilliseconds
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getUTCMilliseconds$_(){throw "don't call me, used for reflection.";}
/**
* Sets the milliseconds in a Date object according to universal time (from 0-999).
* @name setUTCMilliseconds
* @param {Number} _milliseconds
* @memberof Date
* @function
*/
/** @ignore */
instance _$setUTCMilliseconds$_(_milliseconds){throw "don't call me, used for reflection.";}
/**
* Returns the number of milliseconds since midnight Jan 1, 1970.
* @name getTime
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getTime$_(){throw "don't call me, used for reflection.";}
/**
* Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970.
* @name setTime
* @param {Number} _time
* @memberof Date
* @function
*/
/** @ignore */
instance _$setTime$_(_time){throw "don't call me, used for reflection.";}
/**
* Returns the difference in minutes between local time and Greenwich Mean Time (GMT).
* @name getTimezoneOffset
* @return {Number}
* @memberof Date
* @function
*/
/** @ignore */
instance _$getTimezoneOffset$_(){throw "don't call me, used for reflection.";}
/**
* Returns a string representation of the date. Ex... Fri May 09 2008.
* @name toDateString
* @return {String}
* @memberof Date
* @function
*/
/** @ignore */
instance _$toDateString$_(){throw "don't call me, used for reflection.";}
/**
* Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead!
* @name toGMTString
* @memberof Date
* @function
*/
/** @ignore */
instance _$toGMTString$_(){throw "don't call me, used for reflection.";}
/**
* Returns a string representation of the time. Ex... 21:28:42 GMT-0400 (EDT).
* @name toTimeString
* @memberof Date
* @function
*/
/** @ignore */
instance _$toTimeString$_(){throw "don't call me, used for reflection.";}
/**
* Converts a Date object, according to universal time, to a string.
* @name toUTCString
* @memberof Date
* @function
*/
/** @ignore */
instance _$toUTCString$_(){throw "don't call me, used for reflection.";}
/**
* Returns the difference in milliseconds from this date object to _date parameter.
* @return {Number}
* @param {Date} _date
* @return {Number}
*/
instance getDifference(_date)
{
return this.getTime() - _date.getTime();
}
/**
* Returns whether this date object is before _date parameter.
* @param {Date} _date
* @return {Boolean}
*/
instance isBefore(_date)
{
return this.getTime() < _date.getTime();
}
/**
* Returns whether this date object is after _date parameter.
* @param {Date} _date
* @return {Boolean}
*/
instance isAfter(_date)
{
return this.getTime() > _date.getTime();
}
/**
* Returns the number of week in the year. Ex... 29.
* @param {Number} _minimalDaysInFirstWeek
* @return {Number}
*/
// This method was adopted from log4javascript -> http://www.timdown.co.uk/log4javascript
instance getWeekInYear(_minimalDaysInFirstWeek)
{
if(Object.isUndefined(_minimalDaysInFirstWeek)) {
_minimalDaysInFirstWeek = Date.DEFAULT_MINIMAL_DAYS_IN_FIRST_WEEK;
}
var _previousSunday = new Date(this.getTime() - (this.getDay() * Date.ONE_DAY_MILLISECONDS));
_previousSunday = new Date(_previousSunday.getFullYear(), _previousSunday.getMonth(), _previousSunday.getDate());
var _startOfYear = new Date(this.getFullYear(), 0, 1);
var _numberOfSundays = _previousSunday.isBefore(_startOfYear) ?
0 : 1 + Math.floor((_previousSunday.getTime() - _startOfYear.getTime()) / Date.ONE_WEEK_MILLISECONDS);
var _weekInYear = _numberOfSundays;
var _numberOfDaysInFirstWeek = 7 - _startOfYear.getDay();
if(_numberOfDaysInFirstWeek >= _minimalDaysInFirstWeek)
{
_weekInYear++;
}
return _weekInYear;
}
/**
* Returns the number of week in the month. Ex... 4.
* @param {Number} _minimalDaysInFirstWeek
* @return {Number}
*/
// This method was adopted from log4javascript -> http://www.timdown.co.uk/log4javascript
instance getWeekInMonth(_minimalDaysInFirstWeek)
{
if(Object.isUndefined(_minimalDaysInFirstWeek)) {
_minimalDaysInFirstWeek = Date.DEFAULT_MINIMAL_DAYS_IN_FIRST_WEEK;
}
var _previousSunday = new Date(this.getTime() - (this.getDay() * Date.ONE_DAY_MILLISECONDS));
_previousSunday = new Date(_previousSunday.getFullYear(), _previousSunday.getMonth(), _previousSunday.getDate());
var _startOfMonth = new Date(this.getFullYear(), this.getMonth(), 1);
var _numberOfSundays = _previousSunday.isBefore(_startOfMonth) ?
0 : Math.floor((_previousSunday.getTime() - _startOfMonth.getTime()) / Date.ONE_WEEK_MILLISECONDS);
var _weekInMonth = _numberOfSundays;
var _numberOfDaysInFirstWeek = 7 - _startOfMonth.getDay();
if(_numberOfDaysInFirstWeek >= _minimalDaysInFirstWeek)
{
_weekInMonth++;
}
return _weekInMonth;
}
/**
* Returns the day in the year. Ex... 360.
* @return {Number}
*/
// This method was adopted from log4javascript -> http://www.timdown.co.uk/log4javascript
instance getDayInYear()
{
var _startOfYear = new Date(this.getFullYear(), 0, 1);
return 1 + Math.floor((this.getTime() - _startOfYear.getTime()) / Date.ONE_DAY_MILLISECONDS);
}
/**
* Not Implemented.
* @return {String}
*/
instance getTimeZone()
{
var _timezone = "xxx";
//var _timezoneOffset = this.getTimezoneOffset();
return _timezone;
}
/**
* Returns whether this object is equal to the specified _object.
* @param {Object} _object
* @return {Boolean}
*/
instance equals(_object)
{
if(this === _object)
{
return true;
}
if(!this.getClass().isInstance(_object))
{
return false;
}
return this.getTime() == _object.getTime();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?