Git Product home page Git Product logo

jalali-moment's Introduction

Jalali Moment

Display, parse, manipulate and validate jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times and also convert Jalali (Persian, Khorshidi, Shamsi) date to Gregorian (Miladi) or vice versa in javascript or typescript. DEMO

Read this in other languages: فارسی

It was a fork of moment-jalali but the main goal of this repository is to facilitate converting any library using moment.js to be compatible with jalali calendar system. List of packages use jalali-moment to convert calendar system.

MIT License Build Status NPM version Package Quality dependencies Quality dev dependencies Quality Codacy Badge Codacy Badge

Please take a look at day.js, jalaliday module.

How to

  • Install

  • Use jalali moment in

  • Use API

    This plugin provides using jalali and gregorian calendar system together on momentjs api.

    .locale('fa'); it will use jalali calendar system

    .locale('any other locale'); it will use gregorian calendar system

    You can set locale for a moment instance(locally) or set it globally example of changing locale locally

    const m = moment();
    m.locale('fa');
    m.format('YY-MM-DD'); // it would be in jalali system

    change locale globally

    moment.locale('fa');
    moment().format();// it would be in jalali system
    moment().add(1,'m').format();// it would be in jalali system

    Notice : When you need parse a date which is not in the system you have set for global locale you can use of method moment.from(date, 'another locale')

    moment.locale('fa');
    moment.from('2018-04-04', 'en', 'YYYY-MM-DD').format();// it would be in jalali system

    When locale is globally set to 'fa', it's also possible to use gregorian calendar for parsing a date. By setting { useGregorianParser: true } as second parameter of .locale() you can reach this. useGregorianParser default value is false in 'fa' locale.

    moment.locale('fa', { useGregorianParser: true });  
    moment('2018-04-04').format();// it would be in jalali system  
    moment('2019-01-17T08:19:19.975Z').format();// it would be in jalali system  

Usage

  • Parse
    // parse gregorian date
    m = moment('1989/1/24', 'YYYY/M/D');// parse a gregorian (miladi) date
    m = moment.from('01/1989/24', 'en', 'MM/YYYY/DD');
    
    // parse jalali date
    m = moment('1367/11/04', 'jYYYY/jMM/jDD');
    m = moment.from('1367/04/11', 'fa', 'YYYY/MM/DD');
    m = moment.from('04/1367/11', 'fa', 'DD/YYYY/MM');
  • Display
    m.format('jYYYY/jMM/jDD'); // 1367/11/04
    m.locale('fa').format('YYYY/MM/DD'); // 1367/11/04
  • Manipulate
    m.add(1, 'day').locale('fa').format('YYYY/MM/DD'); // 1367/11/05
  • Validate
    m.isSame(m.clone()); // true
  • Convert
    moment.from('1367/11/04', 'fa', 'YYYY/MM/DD').format('YYYY/MM/DD'); // 1989/01/24
    moment('1989/01/24', 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD'); // 1367/11/04

Introduction

jalali(Persian) calendar is a solar calendar system. It gains approximately 1 day on the Julian calendar every 128 years. Read more on Wikipedia.

Calendar conversion is based on the algorithm provided by Kazimierz M. Borkowski and has a very good performance.

This plugin adds Jalali (Persian, Khorshidi, Shamsi) calendar system to moment.js library.

Install

Install via npm

npm install jalali-moment -S

Install via yarn

yarn add jalali-moment

Install via bower

bower install jalali-moment --save

Using in Node.js

Install it via npm or yarn then use it as the following code

var moment = require('jalali-moment');
moment().locale('fa').format('YYYY/M/D');

Using in browser

ES5

get library using bower, npm, cdn, or cloning the repository

<!--<script src="bower_components/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<!--<script src="node_modules/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<script src="https://unpkg.com/jalali-moment/dist/jalali-moment.browser.js"></script>
<!--<script src="thisRepositoryPath/dist/jalali-moment.browser.js"></script>-->

<script>
  moment().locale('fa').format('YYYY/M/D');
</script>

React

import moment from 'jalali-moment'
...
render() {
    return (
        <div>
            {
            this.props.data.map((post,key) =>
                <div key={key} className='post-detail'>
                    <h1>{post.title}</h1>
                    <p>{moment(post.date, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD')}</p>
                    <hr />
                </div>
            )}
        </div>
    );
}

Typescript

import * as moment from 'jalali-moment';
let todayJalali = moment().locale('fa').format('YYYY/M/D');

Angular

import * as moment from 'jalali-moment';

Add a pipe

@Pipe({
  name: 'jalali'
})
export class JalaliPipe implements PipeTransform {
  transform(value: any, args?: any): any {
    let MomentDate = moment(value, 'YYYY/MM/DD');
    return MomentDate.locale('fa').format('YYYY/M/D');
  }
}

and use it in component template

 <div>{{ loadedData.date | jalali }}</div>

Aurelia

You can create a value converters like following:

import { valueConverter } from 'aurelia-framework';
var moment = require('jalali-moment');


@valueConverter('date')
export class DateValueConverter {
  toView(value: string, format: string = 'YYYY/MM/DD', locale: string = 'en') {
    if (!value) return null;
    return moment(value, 'YYYY/MM/DD').locale(locale).format(format);
  }
}

then use this value converter in your html files:

<require from="path_to_your_date_value_converter"></require>

<h1 style="direction:ltr">
    <span>
        ${myDate|date:myFormat:options.locale}
    </span>
</h1>

also, for aurelia developers, there is a plugin, aurelia-time, in which there are value converters for jalali-moment and other time and date libraries.

Vue

Use vue-jalali-moment library

<span>{{ someDate | moment('dddd, MMMM Do YYYY') }}</span>

Command Line

Its cli needs to get installed globally

npm i -g jalali-moment

Then you will be able to convert Persian date to Gregorian and vice versa in terminal or command line as the following

jalalim tojalali 1989/1/24
jalalim togregorian 1392/5/8

If you want something faster, checkout https://github.com/NightMachinary/jalalicli:

❯ hyperfine --warmup 5 'jalalicli tojalali 2001/09/11' 'jalalim tojalali 2001/09/11'
Benchmark #1: jalalicli tojalali 2001/09/11
  Time (mean ± σ):       4.4 ms ±  13.3 ms    [User: 2.8 ms, System: 2.8 ms]
  Range (min … max):     0.0 ms … 107.0 ms    97 runs

Benchmark #2: jalalim tojalali 2001/09/11
  Time (mean ± σ):     148.9 ms ±  76.5 ms    [User: 88.5 ms, System: 19.4 ms]
  Range (min … max):    96.9 ms … 343.0 ms    21 runs

Summary
  'jalalicli tojalali 2001/09/11' ran
   33.88 ± 103.80 times faster than 'jalalim tojalali 2001/09/11'

Jquery

get library using bower, npm, cdn, or cloning the repository

<!--<script src="bower_components/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<!--<script src="node_modules/jalali-moment/dist/jalali-moment.browser.js"></script>-->
<script src="https://unpkg.com/jalali-moment/dist/jalali-moment.browser.js"></script>
<!--<script src="thisRepositoryPath/dist/jalali-moment.browser.js"></script>-->

<script>
  $("#show-date").text(moment().locale('fa').format('YYYY/M/D'));
</script>

API

This plugin tries to change calendar system moment.js api by using locale method.

now = moment(); //get the current date and time,

Parse

Create a instance of moment from a Jalali (Persian) or Miladi date and time as string.more

gregorian date
m = moment('1989/1/24', 'YYYY/M/D');
m = moment.from('1989/1/24', 'en', 'YYYY/M/D');
m = moment.from('01/1989/24', 'en', 'MM/YYYY/DD');
persian date
m = moment('1367/11/4', 'jYYYY/jM/jD');
m = moment.from('1367/11/04', 'fa', 'YYYY/MM/DD');
m = moment.from('11/1367/04', 'fa', 'MM/YYYY/DD');

// it will change locale for all new moment instance
moment.locale('fa');
m = moment('1367/11/04', 'YYYY/M/D');

Display jalali or miladi date

Display moment instance as a string.more

moment.locale('en'); // default locale is en
m = moment('1989/1/24', 'YYYY/M/D');
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('jYYYY/jM/jD [is] YYYY/M/D'); // 1367/11/4 is 1989/1/24

Manipulate

There are a number of methods to modify date and time.more

m.locale('fa');
m.year(1368); // set jalali year
//  If the range is exceeded, it will bubble up to the year.
m.month(3); // month will be 4 and m.format('M')=='4' , jMonth Accepts numbers from 0 to 11.
m.date(10); // set a date
m.format('YYYY/MM/D'); // 1368/4/10
m.subtract(1, 'year'); // subtract a Jalali Year
m.format('YYYY/MM/D'); // 1367/4/10
m.add(2, 'month'); // add two shamsi Month
m.format('YYYY/MM/D'); // 1367/6/10
m.endOf('month').format('YYYY/MM/D'); // 1367/6/31
m.startOf('year').format('YYYY/MM/D'); // 1367/1/1

Validate

Check a date and time.more

m = moment('1367/11/4', 'jYYYY/jM/jD');
m.locale('fa');
m.isLeapYear(); // 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
moment('1396/7/31' ,'jYYYY/jM/jD').isValid(); // false

validation demo in plunker

Convert persian(Jalali , Shamsi, khorshidi) to gregorian (miladi) calendar system

moment.from('1392/6/3 16:40', 'fa', 'YYYY/M/D HH:mm')
    .format('YYYY-M-D HH:mm:ss'); // 2013-8-25 16:40:00

Convert gregorian (miladi) to jalali (Shamsi, persian)

moment('2013-8-25 16:40:00', 'YYYY-M-D HH:mm:ss')
    .locale('fa')
    .format('YYYY/M/D HH:mm:ss'); // 1392/6/31 23:59:59

Change calendar system on changing its locale

moment.bindCalendarSystemAndLocale();

An example usage:

To make a datePicker work with jalali(shamsi) calendar system you could use this ability.

Using in Plunker

ES5

<script src='https://unpkg.com/jalali-moment/dist/jalali-moment.browser.js'></script>
<script>
  moment().locale('fa').format('YYYY/M/D');
</script>

es5 demo in plunker

Typescript or es6

You could use systemjs to import this library into your project like this

Related Projects

jalali-angular-datepicker ( angular2 or more)

A highly configurable date picker built for Angular 4 or Angular 2 applications using jalali-moment is fingerpich/jalali-angular-datepicker created by @Fingerpich.

jalaali-moment

A Jalaali calendar system plugin for moment.js is jalaali-moment.

aurelia-time

aurelia-time Contains a set of value converters for Aurelia, one which uses jalali-moment.

jalali-moment's People

Contributors

ahmadx87 avatar arastu avatar behrang avatar behzad888 avatar bitdeli-chef avatar dependabot[bot] avatar fingerpich avatar hamedfathi avatar lordversa avatar mehdykarimpour avatar miladmeidanshahi avatar mvalipour avatar nightmachinery avatar pouriamaleki avatar pouyamn avatar rzkhosroshahi avatar saadatfar avatar saeedrahimi avatar sajadkiani avatar shahabganji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jalali-moment's Issues

moment deprecation warning

hi there

first off thank you for creating this kind of amazing pkg and sharing it with us

i used to use this pkg for along time ago and by then there was no problems with moment stuff in it
but recently i just facing with this error in my terminal yelling mew about deprecation warnings like below( pm2 log in my terminal ):

0|myTmpProject  | 2019-01-08 10:21: Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.

here is the code that is use in my react project:

let _date = dateCreated.split('T')[0]
_date = moment(_date, 'YYYY-MM-DD').locale('fa').format('YYYY/MM/DD')

basically I'm just getting a time stamp from mongo which looks like this:2019-01-05T14:14:10.305Z

i also tried this out:

    __date = _date.split('-')
    _date = moment.updateLocale( 'fa', {
      longDateFormat: {
        L:'YYYY/MM/DD'
      },
      relativeTime: {
        d: __date[2],
        m: __date[1],
        y: __date[0]
      }
    })

but no result i got yet...

it works but i'm worries about future as it warns me about deprecation stuff that goes on in moment js team.

any kinda response would be appreciated.

thanks alot

angular create library error

hello
import * as moment_ from 'jalali-moment';
in create library raised error :
src/app/components/persian-date-time/persian-date-time.component.ts(67,15): error TS2503: Cannot find namespace 'moment'.

demo page

demo page to show this library abilities

it is imported wrongly by code completions

when i use code completion to import jalali moment it imports it in a wrong way.

it should import as it mentioned in README like bellow.
import * as moment from 'jalali-moment';

Error with existing [email protected]

First of all thanks for you nice work.
When I use in my node project which already dependent to [email protected] I've got this message:
//*** code
const shamsi =jmoment('2014/01/24').locale('fa').format('YYYY/MM/DD');

//*** what it shows in console:
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: 1989/01/24, _f: undefined, _strict: undefined, _locale: [object Object]
Error ...........

Thanks again.
Mohammad

Force to supporting jalali calender

I use this module to localizing mat-datepicker and in some cases it call functions without argument ( e.g. year() return Gregorian year ).

I want to know why year, month and ... functions return Gregorian instead of jalali when they call without argument.

Thank you for your effort

[FEATURE REQUEST] Add CLI tool

Add a CLI tool to easily use these capabilities. Most useful for me personally are the two commands GregorianToJalali and JalaliToGregorian.

Warning

moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale()
This is the warning that i get in console.

  at F.lang
  at F.push../node_modules/jalali-moment/jalali-moment.js.jMoment.fn.jMonth 
  at F.push../node_modules/jalali-moment/jalali-moment.js.jMoment.fn.add 

problem with jest

Describe the bug
Hi,
khaste nabashi :)
I faced an issue when I run my tests. the error is: TypeError: jalali_moment_1.default is not a function.
this error solved when I use jalali-moment in typescript usage as you said in docs. but in this situation, I got another error in rollup that said can't call moment namespace :( in simple usage I haven't any error and issue except this error in the test env.
you can see my project here.

Desktop (please complete the following information):

  • OS: macos 10.14.2
  • Browser chrome

Use loadPersian only for one moment instance

loadPersian is a static method which makes all new moment instances to format as a Persian date time but we may need use it just for an instance.
of course bellow code is also available for our purpose

moment.loadPersian();
moment().format('jYYYY');
moment.unloadPersian();

failed to build angular project which using jalali-moment package

Once i use this package in an angular project and run build command it show error as follow:

BUILD ERROR
Cannot call a namespace ('moment')
Error: Cannot call a namespace ('moment')
at error (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:199:15)
at Module.error (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:17170:9)
at CallExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14725:30)
at MemberExpression$$1.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at MemberExpression$$1.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:15672:35)
at CallExpression.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at CallExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14721:31)
at AssignmentExpression.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at AssignmentExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14605:31)
at ExpressionStatement$$1.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)

Cannot call a namespace ('moment')
Error: Cannot call a namespace ('moment')
at error (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:199:15)
at Module.error (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:17170:9)
at CallExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14725:30)
at MemberExpression$$1.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at MemberExpression$$1.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:15672:35)
at CallExpression.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at CallExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14721:31)
at AssignmentExpression.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)
at AssignmentExpression.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:14605:31)
at ExpressionStatement$$1.NodeBase.bind (D:\angular-pro\libraries\node_modules\rollup\dist\rollup.js:13499:23)

Date adapter want to use jalali moment in angular material date picker.
1.I run an angular project with : ng new my-app
2.Then import jalali moment package
3.Create an adapter for date.

Guide for using this adapter can found in : jalali-date-picker

Where is the problem?

update typings

Thank you for your wonderful effort.
Jalali functions such as m.jYear() can not be recognized in vscode, "jalali-moment": "^2.0.4", "@angular / cli": "^1.3.0", "typescript": "~2.3.3".
However your plunkr at https://embed.plnkr.co/Gggh1u/ works fine, even after updating jalali-moment to 2.0.4, and also it does not need moment itself, but I had to npm install "moment" in my angular/cli project.

But in the component after,
import * as pmoment from 'jalali-moment'; and
this.jalaliYear = ( < any > pmoment( ) ).jYear( );
it works as expected.

ISO string as input

Hi,
On this method:

    fromIso8601(iso8601String: string): jmoment.Moment | null {
        const d = jmoment(iso8601String, jmoment.ISO_8601).locale('fa');
        return this.isValid(d) ? d : null;
    }

I get config._f.match is not a function !!!
And these are the tests:

    it('should create dates from valid ISO strings', () => {
        expect(adapter.fromIso8601('1985-04-12T23:20:50.52Z')).not.toBeNull();
        expect(adapter.fromIso8601('1996-12-19T16:39:57-08:00')).not.toBeNull();
        expect(adapter.fromIso8601('1937-01-01T12:00:27.87+00:20')).not.toBeNull();
        expect(adapter.fromIso8601('1990-13-31T23:59:00Z')).toBeNull();
        expect(adapter.fromIso8601('1/1/2017')).toBeNull();
      });

Thanks a lot.

question about months name

Hi,
This is not an issue.
I have a question:
What is the use cases of

extend(getPrototypeOf(moment.localeData()),
    { _jMonths: [ "Farvardin"
        , "Ordibehesht"
        , "Khordaad"
        , "Tir"

Because of an issue in angular material 2 datepicker, if your library could set months name in the above code just to Persian names as moment's locale data, it may help on mentioned issue.
Thanks again.

unix date converting return invalid value for some dates

I want to convert birthday input to unix timestamp. The problem is that it converts to invalid Unix timestamp when I enter birthYear for example '1331'.

Here's my code:

const birthDateInput =`${birthObj.birthYear}/${birthObj.birthMonth}/${birthObj.birthDay}`;
const birthdate = Moment(birthDateInput, 'jYYYY/jM/jD').format('X');

The result for '1331/2/13' is:
-557465400

clone must not change validity

The following code shows the problem

const m = jmoment('hello', 'jMM/jDD/jYYYY', 'fa');
const isMom = jmoment.isMoment(m); // true
const cloned = m.clone().locale('fa');
const v1 = m.isValid(); // false​ it s ok​
const v2 = cloned.isValid(); // true?? why is that​

jalali as a flag

when we want to use some other library that is used moment.js we have to change all function name and formats to jYear or 'jYYYY-jMM-jDD'
but i think we could have a flag to indicate it should treated as a jalali date or gregorian date.

Why jalali-moment packages remove from my project when i install typescript package?

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

How can I import Moment interface to my typescript?

Hello, I need to load the Moment interface to my .ts file.
I can see that the moment() output's interface is moment.Moment, but I cannot import Moment interface to my code.

For example, express provides its interfaces as parameters throw the express value like below:

var res:express.Response ;

And I didn't find such a solution on yours.

Cannot find name 'moment' error

Hi.
I add to my project jalali-moment and add reference of this file into .ts file such as
reference path="../scripts/typings/jquery/jquery.d.ts"
reference path="../scripts/typings/jqueryui/jqueryui.d.ts"
reference path="../scripts/typings/jalali-moment/jalali-moment.ts"
but get error for me that Cannot find name 'moment'.
my tsconfig.json file :
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "../appScriptsJS",
"charset": "utf8"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
typescript :
moment(dateMiladi).locale('fa').format('YYYY/MM/DD');
What is problem?

Relative Time Wrong Calculation

Detailed description

I faced this error when i use .fromNow() method;
start date: "2018-10-25T13:20:00+00:00"
should return: 1 ساعت پیش (for my test time)
result: در 621 سال
it seems the library calculated subtract of 2018 and 1397!

Steps to reproduce

let fromNow = moment("2018-10-25T13:20:00+00:00").locale('fa').fromNow()
// or without locale()
console.log(fromNow)

Ability to change days or month name

we have something bad here ,
Friday has been translated to " آدینه " and it is not normal , please set an ability to change this words ( like a translate sheet )

Date validation

Hi there
Tanks for amazing library
Is there any way to check date is valid or not?

parse persian digit date

When its possible to use persian digits in formatted output, we should make it available to parse persian digits and make instance of moment from it.

Any option to validate jalali date?

Hi Mojtaba, Thank you for the service.
Is there any validation option for jalali dates in this lib? As you know, in momentjs a isValid function doing the similar work. So, can you point out how we can validate jalali dates using jalali-moment ?
According to your knowledge, What do you do if you want check and validate month, day and year in jalali calendar?

manipulating by day

Does this method works correctly on version 2.1.2?
m.add(1, "jDay");
or
m.add(1 "jD");
inside unitOfTime type base:
jDay and jD
are defined, but they do not work for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.