jalali-moment
Advanced tools
Comparing version 3.0.8 to 3.0.9
@@ -948,3 +948,3 @@ | ||
jMoment.fn.locale = function(locale) { | ||
if (moment.changeCalendarSystemByItsLocale) { | ||
if (locale && moment.changeCalendarSystemByItsLocale) { | ||
if (locale === "fa") { | ||
@@ -962,3 +962,3 @@ this.doAsJalali(); | ||
jMoment.locale = function(locale) { | ||
if (moment.changeCalendarSystemByItsLocale) { | ||
if (locale && moment.changeCalendarSystemByItsLocale) { | ||
if (locale === "fa") { | ||
@@ -965,0 +965,0 @@ this.useJalaliSystemPrimarily(); |
@@ -24,2 +24,3 @@ # Jalali Moment | ||
- [Aurelia](https://github.com/fingerpich/jalali-moment#aurelia) | ||
- [Vue](https://github.com/fingerpich/jalali-moment#vue) | ||
- [Es5](https://github.com/fingerpich/jalali-moment#es5) | ||
@@ -38,22 +39,23 @@ - [Plunker](https://github.com/fingerpich/jalali-moment#using-in-plunker) | ||
- [Parse](https://github.com/fingerpich/jalali-moment#parse) | ||
- [Parse](#parse) | ||
```js | ||
moment.locale('fa'); // set fa locale for all new moment instances | ||
var m1 = moment("1367/11/04","YYYY/MM/DD"); | ||
var m1 = moment("1367/11/04"); | ||
``` | ||
- [Display](https://github.com/fingerpich/jalali-moment#display-jalali-or-miladi-date) | ||
- [Display](#display-jalali-or-miladi-date) | ||
```js | ||
m1.format("YYYY/MM/DD"); // 1367/11/04 | ||
``` | ||
- [Manipulate](https://github.com/fingerpich/jalali-moment#manipulate) | ||
- [Manipulate](#manipulate) | ||
```js | ||
m1.add(1, "day").format("YYYY/MM/DD"); // 1367/11/05 | ||
``` | ||
- [Validate](https://github.com/fingerpich/jalali-moment#validate) | ||
- [Validate](#validate) | ||
```js | ||
m1.isSame(m1.clone()); // true | ||
``` | ||
- [Convert](https://github.com/fingerpich/jalali-moment#convert-persianjalali--shamsi-khorshidi-to-gregorian-miladi-calendar-system) | ||
- [Convert](#convert-persianjalali--shamsi-khorshidi-to-gregorian-miladi-calendar-system) | ||
```js | ||
moment('1367/11/04', 'YYYY/MM/DD').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('fa'); | ||
moment('1367/11/04').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('en'); | ||
@@ -60,0 +62,0 @@ moment('1989/01/24').locale('fa').format('YYYY/MM/DD'); // 1367/11/04 |
{ | ||
"name": "jalali-moment", | ||
"version": "3.0.8", | ||
"version": "3.0.9", | ||
"description": "Display, parse, manipulate ,validate and convert jalali (Persian, Khorshidi, Shamsi) date and time", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -24,2 +24,3 @@ # Jalali Moment | ||
- [Aurelia](#aurelia) | ||
- [Vue](#vue) | ||
- [Es5](#es5) | ||
@@ -41,3 +42,3 @@ - [Plunker](#using-in-plunker) | ||
moment.locale('fa'); // set fa locale for all new moment instances | ||
var m1 = moment("1367/11/04","YYYY/MM/DD"); | ||
var m1 = moment("1367/11/04"); | ||
``` | ||
@@ -58,3 +59,4 @@ - [Display](#display-jalali-or-miladi-date) | ||
```js | ||
moment('1367/11/04', 'YYYY/MM/DD').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('fa'); | ||
moment('1367/11/04').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('en'); | ||
@@ -94,3 +96,3 @@ moment('1989/01/24').locale('fa').format('YYYY/MM/DD'); // 1367/11/04 | ||
var moment = require('jalali-moment'); | ||
moment().format('jYYYY/jM/jD'); | ||
moment().locale('fa').format('YYYY/M/D'); | ||
``` | ||
@@ -107,3 +109,3 @@ | ||
<script> | ||
moment().format('jYYYY/jM/jD'); | ||
moment().locale('fa').format('YYYY/M/D'); | ||
</script> | ||
@@ -116,3 +118,3 @@ ``` | ||
import * as moment from 'jalali-moment'; | ||
let todayJalali = moment().format('jYYYY/jM/jD'); | ||
let todayJalali = moment().locale('fa').format('YYYY/M/D'); | ||
``` | ||
@@ -133,3 +135,3 @@ | ||
let MomentDate = moment(value); | ||
return MomentDate.format("jYYYY/jM/jD"); | ||
return MomentDate.locale('fa').format("YYYY/M/D"); | ||
} | ||
@@ -155,7 +157,4 @@ } | ||
toView(value: string, format: string = "YYYY/MM/DD", locale: string = "en") { | ||
if (!value) | ||
return null; | ||
let m2 = moment(value).locale(locale); | ||
return m2.format(format); | ||
if (!value) return null; | ||
return moment(value).locale(locale).format(format); | ||
} | ||
@@ -179,3 +178,10 @@ } | ||
#### Vue | ||
Use [vue-jalali-moment](https://github.com/fingerpich/vue-jalali-moment) library | ||
```html | ||
<span>{{ someDate | moment("dddd, MMMM Do YYYY") }}</span> | ||
``` | ||
## API | ||
@@ -197,4 +203,6 @@ | ||
m = moment('1989/1/24', 'YYYY/M/D');// parse a gregorian (miladi) date | ||
m = moment('1989/1/24');// parse a gregorian date | ||
moment.locale('fa'); | ||
m = moment('1367/11/4', 'YYYY/M/D');// parse a jalali (persian) date | ||
m = moment('1367/11/04');// parse a jalali (persian) date | ||
``` | ||
@@ -206,13 +214,16 @@ | ||
```js | ||
m.format('jYYYY/jM/jD');// 1367/11/4 | ||
m.format('jMM'); // 11 display jalali month | ||
moment.locale('en'); // default locale is en | ||
m = moment('1989/1/24'); | ||
m.locale('fa'); // change locale for this moment instance | ||
m.format('YYYY/M/D');// 1367/11/4 | ||
m.format('MM'); // 11 display jalali month | ||
m.format('MMMM'); // Bahman | ||
m.format('DD'); // 04 display day by two digit | ||
m.format('DDD'); // 310 display day of year | ||
m.format('w'); // 45 display week of year | ||
m.locale('en'); | ||
m.format('M'); // 1 display miladi month | ||
m.format('MM'); // 01 display month by two digit | ||
m.format('MMMM'); // January | ||
m.format('jMMMM'); // Bahman | ||
m.format('jDD'); // 04 display day by two digit | ||
m.format('jYYYY/jM/jD [is] YYYY/M/D'); // 1367/11/4 is 1989/1/24 | ||
m.jDayOfYear(); // 310 | ||
m.jWeek(); // 45 | ||
m.jWeekYear(); // 1367 | ||
``` | ||
@@ -244,6 +255,6 @@ | ||
m.isLeapYear(); // false | ||
m.isSame('1989-01-01', 'year'); // true | ||
m.isSame(moment('1367-01-01','jYYYY-MM-DD'), 'jyear'); // true | ||
m.isBefore(moment('1367-01-01','jYYYY-MM-DD'), 'jyear'); // false | ||
m.isAfter(moment('1367-01-01','jYYYY-MM-DD'), 'jyear'); // false | ||
m.isSame(moment('1989-01-01','YYYY-MM-DD'), 'year'); // true | ||
m.isSame(moment('1367-01-01','jYYYY-jMM-jDD'), 'year'); // true | ||
m.isBefore(moment('1367-01-01','jYYYY-jMM-jDD'), 'month'); // false | ||
m.isAfter(moment('1367-01-01','jYYYY-jMM-jDD'), 'jyear'); // false | ||
m.isValid(); // true | ||
@@ -250,0 +261,0 @@ moment('1396/7/31','jYYYY/jM/jD').isValid(); // false |
@@ -24,2 +24,3 @@ # Jalali Moment | ||
- [Aurelia](https://github.com/fingerpich/jalali-moment#aurelia) | ||
- [Vue](https://github.com/fingerpich/jalali-moment#vue) | ||
- [Es5](https://github.com/fingerpich/jalali-moment#es5) | ||
@@ -38,22 +39,23 @@ - [Plunker](https://github.com/fingerpich/jalali-moment#using-in-plunker) | ||
- [Parse](https://github.com/fingerpich/jalali-moment#parse) | ||
- [Parse](#parse) | ||
```js | ||
moment.locale('fa'); // set fa locale for all new moment instances | ||
var m1 = moment("1367/11/04","YYYY/MM/DD"); | ||
var m1 = moment("1367/11/04"); | ||
``` | ||
- [Display](https://github.com/fingerpich/jalali-moment#display-jalali-or-miladi-date) | ||
- [Display](#display-jalali-or-miladi-date) | ||
```js | ||
m1.format("YYYY/MM/DD"); // 1367/11/04 | ||
``` | ||
- [Manipulate](https://github.com/fingerpich/jalali-moment#manipulate) | ||
- [Manipulate](#manipulate) | ||
```js | ||
m1.add(1, "day").format("YYYY/MM/DD"); // 1367/11/05 | ||
``` | ||
- [Validate](https://github.com/fingerpich/jalali-moment#validate) | ||
- [Validate](#validate) | ||
```js | ||
m1.isSame(m1.clone()); // true | ||
``` | ||
- [Convert](https://github.com/fingerpich/jalali-moment#convert-persianjalali--shamsi-khorshidi-to-gregorian-miladi-calendar-system) | ||
- [Convert](#convert-persianjalali--shamsi-khorshidi-to-gregorian-miladi-calendar-system) | ||
```js | ||
moment('1367/11/04', 'YYYY/MM/DD').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('fa'); | ||
moment('1367/11/04').locale('en').format('YYYY/MM/DD'); // 1989/01/24 | ||
moment.locale('en'); | ||
@@ -60,0 +62,0 @@ moment('1989/01/24').locale('fa').format('YYYY/MM/DD'); // 1367/11/04 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1628890
88