Comparing version 1.1.1 to 1.2.0
@@ -17,3 +17,3 @@ var $jin = this.$jin = {} | ||
return function (value) { | ||
return first.call(this, value) + second.call(this, value); | ||
return first(value) + second(value); | ||
}; | ||
@@ -527,3 +527,3 @@ } | ||
return ''; | ||
return this.monthLong[moment.month]; | ||
return moment.constructor.monthLong[moment.month]; | ||
}, | ||
@@ -533,3 +533,3 @@ 'Mon': function (moment) { | ||
return ''; | ||
return this.monthShort[moment.month]; | ||
return moment.constructor.monthShort[moment.month]; | ||
}, | ||
@@ -539,3 +539,3 @@ '-MM': function (moment) { | ||
return ''; | ||
return '-' + this.patterns['MM'](moment); | ||
return '-' + moment.constructor.patterns['MM'](moment); | ||
}, | ||
@@ -558,3 +558,3 @@ 'MM': function (moment) { | ||
return ''; | ||
return this.weekDayLong[moment.weekDay]; | ||
return moment.constructor.weekDayLong[moment.weekDay]; | ||
}, | ||
@@ -564,3 +564,3 @@ 'WD': function (moment) { | ||
return ''; | ||
return this.weekDayShort[moment.weekDay]; | ||
return moment.constructor.weekDayShort[moment.weekDay]; | ||
}, | ||
@@ -570,3 +570,3 @@ '-DD': function (moment) { | ||
return ''; | ||
return '-' + this.patterns['DD'](moment); | ||
return '-' + moment.constructor.patterns['DD'](moment); | ||
}, | ||
@@ -589,3 +589,3 @@ 'DD': function (moment) { | ||
return ''; | ||
return 'T' + this.patterns['hh'](moment); | ||
return 'T' + moment.constructor.patterns['hh'](moment); | ||
}, | ||
@@ -607,3 +607,3 @@ 'hh': function (moment) { | ||
return ''; | ||
return ':' + this.patterns['mm'](moment); | ||
return ':' + moment.constructor.patterns['mm'](moment); | ||
}, | ||
@@ -625,3 +625,3 @@ 'mm': function (moment) { | ||
return ''; | ||
return ':' + this.patterns['ss'](moment); | ||
return ':' + moment.constructor.patterns['ss'](moment); | ||
}, | ||
@@ -646,3 +646,3 @@ 'ss': function (moment) { | ||
return ''; | ||
return '.' + this.patterns['sss'](moment); | ||
return '.' + moment.constructor.patterns['sss'](moment); | ||
}, | ||
@@ -674,2 +674,16 @@ 'sss': function (moment) { | ||
time.moment = moment_class.make.bind(moment_class); | ||
time.moment['en'] = moment_class.make.bind(moment_class); | ||
var moment_class_ru = (function (_super) { | ||
__extends(moment_class_ru, _super); | ||
function moment_class_ru() { | ||
_super.apply(this, arguments); | ||
} | ||
moment_class_ru.monthLong = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; | ||
moment_class_ru.monthShort = ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек']; | ||
moment_class_ru.weekDayLong = ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота']; | ||
moment_class_ru.weekDayShort = ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб']; | ||
return moment_class_ru; | ||
})(moment_class); | ||
time.moment_class_ru = moment_class_ru; | ||
time.moment['ru'] = moment_class_ru.make.bind(moment_class_ru); | ||
})(time = $jin.time || ($jin.time = {})); | ||
@@ -676,0 +690,0 @@ })($jin || ($jin = {})); |
{ | ||
"name": "jin-time", | ||
"description": "Cool date/time/duration/range arithmetic", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "jin <nin-jin@ya.ru>" |
@@ -45,2 +45,8 @@ # $jin.time | ||
Speed of iso8601 parsing: | ||
```js | ||
console.time('test') ; for( var i = 0 ; i < 10000 ; ++i ) new Date( '2015-07-20T07:48:28.338+03:00' ) ; console.timeEnd('test') | ||
// 13ms | ||
``` | ||
## MomentJS | ||
@@ -61,2 +67,8 @@ | ||
Speed of iso8601 parsing: | ||
```js | ||
console.time('test') ; for( var i = 0 ; i < 10000 ; ++i ) moment( '2015-07-20T07:48:28.338+03:00' ) ; console.timeEnd('test') | ||
// 440ms | ||
``` | ||
## $jin.time | ||
@@ -76,2 +88,8 @@ | ||
Speed of iso8601 parsing: | ||
```js | ||
console.time('test') ; for( var i = 0 ; i < 10000 ; ++i ) $jin.time.moment( '2015-07-20T07:48:28.338+03:00' ) ; console.timeEnd('test') | ||
// 65ms | ||
``` | ||
# API | ||
@@ -159,2 +177,15 @@ | ||
### Serialization | ||
```js | ||
$jin.time.moment().toString( 'YYYY-MM-DD hh:mm (WeekDay)' ) // "2015-07-20 07:22 (Monday)" | ||
``` | ||
Mnemonics: | ||
* single letter for numbers: M - month number, D - day of month. | ||
* uppercase letters for dates, lowercase for times: M - month number , m - minutes number | ||
* repeated letters for define register count: YYYY - full year, YY - shot year, MM - padded month number | ||
* words for word representation: Month - month name, WeekDay - day of week name | ||
* shortcuts: WD - short day of week, Mon - short month name. | ||
## Durations | ||
@@ -194,3 +225,3 @@ | ||
var dur = $jin.time.duration() | ||
dur.year // number | ||
durdur.year // number | ||
dur.month // number | ||
@@ -228,12 +259,12 @@ dur.day // number | ||
$jin.time.range( '2015-07-19/2015-08-02' ) // by two moments | ||
$jin.time.range( '2015-07-19/P14D' ) // by start moment and duration | ||
$jin.time.range( 'P14D/2015-08-02' ) // by end moment and duration | ||
$jin.time.range( '2015-07-19/P14D' ) // by two start moment and duration | ||
$jin.time.range( 'P14D/2015-08-02' ) // by two end moment and duration | ||
// by components | ||
$jin.time.range({ | ||
from : '2015-07-19' , | ||
to : '2015-08-02' , | ||
start : '2015-07-19' , | ||
end : '2015-08-02' , | ||
}) | ||
$jin.time.range({ | ||
from : '2015-07-19' , | ||
start : '2015-07-19' , | ||
duration : 'P14D' , | ||
@@ -243,3 +274,3 @@ }) | ||
duration : 'P14D' , | ||
to : '2015-08-02' , | ||
end : '2015-08-02' , | ||
}) | ||
@@ -257,4 +288,4 @@ | ||
// component value (third are calculated by defined two) | ||
$jin.time.range( '2015/P1Y' ).to // $jin.time.moment( '2016' ) | ||
$jin.time.range( 'P1Y/2016' ).from // $jin.time.moment( '2015' ) | ||
$jin.time.range( '2015/P1Y' ).end // $jin.time.moment( '2016' ) | ||
$jin.time.range( 'P1Y/2016' ).start // $jin.time.moment( '2015' ) | ||
$jin.time.range( '2015/2016' ).duration // $jin.time.duration( 'PT31536000S' ) | ||
@@ -267,2 +298,22 @@ | ||
## Localization | ||
To add some language support use typescript subclassing: | ||
```js | ||
class moment_class_ru extends $jin.time.moment_class { | ||
static monthLong = [ '������', '�������', '����', '������', '���', '����', '����', '������', '��������', '�������', '������', '�������' ] | ||
static monthShort = [ '���', '���', '���', '���', '���', '���', '���', '���', '���', '���', '���', '���' ] | ||
static weekDayLong = [ '�����������', '�����������', '�������', '�����', '�������', '�������', '�������' ] | ||
static weekDayShort = [ '��', '��', '��', '��', '��', '��', '��' ] | ||
} | ||
$jin.time.moment['ru'] = moment_class_ru.make.bind( moment_class_ru ) | ||
``` | ||
Then you can use it: | ||
```js | ||
$jin.time.moment['ru']().toString( 'YYYY-MM-DD (WD)' ) // "2015-07-20 (��)" | ||
``` | ||
## To Do | ||
@@ -269,0 +320,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44202
797
315