Code Monkey home page Code Monkey logo

moment-hijri's People

Contributors

agent3bood avatar glittle avatar ibrahimlawal avatar leyendecker avatar msarhan avatar oneoeigh avatar ronrother avatar rubiabornhofen avatar svieira avatar vhkrausser avatar xsoh 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

moment-hijri's Issues

Not working with typescript angular 2

Trying to add it into my Angular 2 typescript project through npm install moment-hijri but getting following error on terminal:

Cannot find module 'moment-hijri'

I have these parameters set in my tsconfig.json:

    "module": "es6",
    "moduleResolution": "node",

Also tried with module setting 'commonjs' and 'amd' but its the same error.

date.locale() returns undefined. Errors when using with antd DatePicker

If moment-hijri object is passed to DatePicker from antd as value prop; then DatePicker errors because return of value.locale() is undefined

minimal codes to reproduce

import moment from "moment-hijri";
import { DatePicker } from "antd";

export default const HijriDatePicker = (props) => {
  return <DatePicker value={props.value} format="DD-MM-YYYY (iDD-iMM-iYYYY)" />
}

Here is CodeSandbox link to test it live.

Hijri Moment Not Working

Kindly i was try to add (moment hijri) but still not working , can you give me the steps with small explain ?

Eonasdan's bootstrap datetimepicker

Thanks for this git
Please take a look at Eonasdan's bootstrap datetimepicker here
it uses moment with locales
is there any way i can implement your script with it
the page freezes when i load moment-hijri
thank you very much

Moment Hijri offset problems?

Hello,

Is there any offset issues with the conversion calculations?

I've read that converting hijri-gregorian or gregorian-hijri may have one day offset.

This situation can happen with this plugin too?

Illogical return from isSame()

Description: comparing 1443/11/01 to 1443/10/01 returns true also it should return false

Steps to replicate the bug: moment('1443/11/01', 'iYYYY/iMM/iDD').isSame(moment('1443/10/01', 'iYYYY/iMM/iDD'),'month')

iDaysInMonth() returns NaN

Hi!

Getting the number of days in the month doesn't work.

Method iDaysInMonth() returns value 'NaN'.

Workaround:
Method endOf('iMonth').iDate() return value correctly.

Incorrect dates convertion

I converted dates for +- 5 years interval from now to be sure it matches Hijri dates given by MS Umm al-Qura calendar and found 1 mismatch:
moment('2024-12-02').format('YYYY-M-D [is] iYYYY-iM-iD') // 2024-12-2 is 1446-5-30
But according to http://www.ummulqura.org.sa and other resources, it should be 1446-6-1

considered valid but wrong ?

Hi
moment('14/14/1436', 'iDD/iMM/iYYYY').isValid() returns true....
moment('30/455/1436', 'iDD/iMM/iYYYY').isValid() returns true....

or what am I doing wrong ?

thanks

iDaysInMonth() gives number of days as 1 for some month of a year

I am trying to find number of days in a hijri year, for that I'm looping over days in months and found strange case that for 1 month of the year the number of days returned is 1.

Please observe the attached images.
This is an urgent issue. I have chosen this library and started it's implementation. this case is disrupting a major flow.

This is for timezone America/New_York and I'm using moment-timezone for setting zones

daysInmonthissue1

daysInmonthissue2

moment().endOf('hUnit') is not working ..

Hi,
Thank you very much for making this plugin ๐Ÿ‘ .
I'm trying to execute this line (from the readme)

moment('2014-11-28 16:40:00', 'YYYY-M-D HH:mm:ss').endOf('hMonth').format('hYYYY/hM/hD HH:mm:ss'); // 1436/2/30 23:59:59

it doesn't give the result mentioned in the comment 1436/2/30 23:59:59 and also tried many variants, it looks like endOf method is not affecting the date if given hmounth or hyear or anything outside the standard moment units.

Any thoughts about this ?

Why dates beyond 1500 AH not supported.

We are using the moment-hijri in a datepicker component. There we have noticed that if we try to get a date of 1501 or above it returns NaN. Infact I can see the comments in js also that it will return dates till year 1500 only. Any particular reason for this?

Parse logic doesn't match format logic

import * as momentHijri from 'moment-hijri'

momentHijri.locale('ar-SA')
momentHijri(momentHijri().format('iYYYY/iMM/iDD'), 'iYYYY/iMM/iDD').isValid()

Running this code returns false for me --- I would expect to be able to parse a value using the same format string used to generate it. Looking at the code, it might be because the parse logic isn't handling the Arabic numerals, ie: with my above format string, the parse would only handle '1111-11-11' format.

How do i get month name?

console.log(m._iMonths[m.iMonth()])

is this correct ? it is not showing anything tho(undefined)

Should parse when only Hijri date is in the format

Should parse when only Hijri date is in the format

it('should parse when only Hijri date is in the format', function() {
    var m = moment('1990 28 3', 'YYYY hD M')
    m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
})

Should parse when only Hijri month is in the format

Should parse when only Hijri month is in the format

 it('should parse when only Hijri month is in the format', function() {
     var m = moment('1990 08 25', 'YYYY hM D')
     m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
 })

string.indexOf is not a function

When i trying to convert the moment hijri date to gregorian, i am facing the problem

moment("arabic date time", "iM-iD-iYYYY H:mm).format('M-D-YYYY')

I got the exception string.indexOf is not a function

daysInMonth always return gregorian month lengh

Please how i can get hijri month lenght, i am using daysInMonth but it always return gregorian month lengh.
here is my code

var m = moment('1410/8/28', 'iYYYY/iM/iD');

      var v1=  m.iYear(); // 1410
      var v2 = m.iMonth(); // 7
      var v3 = m.iDate(); // 28
      var v4 = m.iDayOfYear(); // 236
      var v5 = m.iWeek(); // 35
      var v6 = m.iWeekYear(); // 1410
      var v7= m.daysInMonth();

Shawwal month not return from moment hijri (2022)

When I try to print the current month's name which is Shawwal, it always returns Ramadan this happened only in the 2022 year if I try past or next year it works fine

moment().add(1, "year").startOf("month").format("iMMMM")

Difference between this library and Um Alqura

Hello everyone,
Thanks for a great project. I tried to use this library and it works most of the time but I faced some issues with the following dates:
1381,7,1
1980, 3, 31
1956, 12, 30
I get the wrong date for them compared to Um Alqura website. The converted date is off by one day.

Should parse when only Hijri year is in the format

Should parse when only Hijri year is in the format

it('should parse when only Hijri year is in the format', function() {
      var m = moment('03 1410 25', 'MM hYYYY DD')
      m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
      m = moment('03 10 25', 'MM hYY DD')
      m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
    })

iMonth return wrong value

Hi, (ุงู„ุณู„ุงู… ุนู„ูŠูƒู…)
iMonth function return wrong value, for example the date is 1439/8/19 in this case it should return 8 but it returns 7 .

Thank You

ุชุณุงุคู„: ู…ุชู‰ ูŠุจุฏุฃ ุงู„ูŠูˆู… ููŠ ุงู„ุชู‚ูˆูŠู… ุงู„ู‡ุฌุฑูŠ

ู…ุซู„ุง ููŠ ุงู„ุนูŠุฏ ุนู†ุฏู…ุง ู†ุจุฏุฃ ุงู„ุชูƒุจูŠุฑุงุช ู„ูŠู„ุงุŒ ุฃูˆ ุนู†ุฏู…ุง ู†ู‚ูˆู„ ู„ูŠู„ุฉ ุงู„ุฌู…ุนุฉ ูˆุงู„ู…ู‚ุตูˆุฏ
ู‡ู†ุง ู‡ูˆ ุงู„ู„ูŠู„ุฉ ุงู„ุชูŠ ุชุณุจู‚ ุงู„ู†ู‡ุงุฑุŒ ุฃูŠ ุฃู† ุงู„ู„ูŠู„ ูŠุฃุชูŠ ุซู… ูŠุฃุชูŠ ุงู„ู†ู‡ุงุฑ ููŠ ุงู„ุชู‚ูˆูŠู… ุงู„ู‡ุฌุฑูŠุŒ ุฃูŠ ุฃู† ุงู„ูŠูˆู… ูŠุจุฏุฃ ุนู†ุฏ ู…ุบุฑุจ ุงู„ุดู…ุณ


https://www.marefa.org/%D8%A7%D9%84%D9%8A%D9%88%D9%85_%D8%A7%D9%84%D8%A5%D8%B3%D9%84%D8%A7%D9%85%D9%8A

ูู‡ู…ุช ู…ู† ู‡ู†ุง ุฃู† ุงู„ู†ู‡ุงุฑ ููŠ ุงู„ุชู‚ูˆูŠู… ุงู„ู‡ุฌุฑูŠ ู‡ูˆ ู…ู† ุงู„ุดุฑูˆู‚ ุญุชู‰ ุงู„ุบุฑูˆุจ ูˆุงู„ู„ูŠู„ ู‡ูˆ ู…ู† ุงู„ุบุฑูˆุจ ุญุชู‰ ุงู„ุดุฑูˆู‚ ๐ŸŒžุŒ ูˆุฃู† ุงู„ูŠูˆู… ุงู„ูŠูˆู… ูŠุชูƒูˆู† ู…ู† ุงู„ู„ูŠู„ ุซู… ุงู„ู†ู‡ุงุฑ.

Parsing using iMMM returns incorrect date (off by one month)

When parsing the month from iMMM format it uses a one-based index. So, Shw is month 10, but then it converts it to the Gregorian equivalent using zero-based index and so it is off by one month.

    const input = '22 Shw 1440';
    const output = moment(input, 'iDD iMMM iYYYY').format('iDD iMMM iYYYY');
    if (input !== output) {
        console.log(`${input} returned ${output}`);
    }

output is "22 Shw 1440 returned 22 Dhu-Q 1440"

How can I initialize moment hijri with millesconds and get the hijri date

Hello,

I am trying to get the hijri date based on unix time but i am getting gregorian date instead.

const justNow = new Date();
const momentHijriNow = momentHijri.unix(justNow.valueOf() / 1000);
console.log('momentHijri now', momentHijriNow.format('iYYYY/iM/iD')); // momentHijri now i2019/i2/i6

Maybe I am doing really wrong :S

Thanks for your job ;)

Export as high order function

Hello. I'm concerned using this library has implicit conflicts with other plugins. By adding methods to the singleton moment object at import time, it's possible to have conflicts at a distance in an app.

I'd advocate for exporting a "High Order Function" instead, so that the consumer can decide when/where to apply the plugin, and that will leave the original module unmodified.

ie:

require('moment');
var moment = require('moment-hijri');

becomes

var moment = require('moment-hijri')(require('moment'));

or in es6

import moment from 'moment';
import hijriify from 'moment-hijri';

const hijriMoment = hijiriify(moment);

Also remove need for AMD export in repo, as AMD projects could do:

define(['moment', 'moment-hijri'], function(moment, hijriify) {
  var hijriMoment = hijriify(moment);
});

Typescript Support

Are you planning to support typescript or even provide a typing for your lib ?

Parse logic doesn't match format logic

import * as momentHijri from 'moment-hijri'

momentHijri.locale('ar-SA')
momentHijri(momentHijri().format('iYYYY/iMM/iDD'), 'iYYYY/iMM/iDD').isValid()

Running this code returns false for me --- I would expect to be able to parse a value using the same format string used to generate it. Looking at the code, it might be because the parse logic isn't handling the Arabic numerals, ie: with my above format string, the parse would only handle '1111-11-11' format.

Uncaught TypeError: s.indexOf is not a function

I'm using moment to make a calendar and this line is throwing the above error:

ev.date = moment(ev.eventTime, "YYYY-MM-DD");

where eventTime is:
{eventName: 'Interview - Jr. Web Developer', calendar: 'Work', color: 'orange', eventTime: moment("2020-05-16")},

The calendar works without moment-hijri dependency but I want to add hijri dates to the calendar.I haven't parsed hijri dates so far.

This line from moment-hijri.js is throwing the error:

string = string.slice(string.indexOf(parsedInput) + parsedInput.length)

[Question] timezone

Assalam, How can I change timezone for Hijri moment because default moment-hijri current date not same as my country (Malaysia)

Hijri date with datetimepicker

Am no sure if I should be posting the issue here or in the Git of the datetimepicker, however whenever I try to use the moment-hijri with the bootstrap-datetimepicker and setting the format at 'iDD/iMM/iYYYY' I keep getting the 'i' in front of the days/months/years and yes I did include the ar-sa file for moment.
So if you could please help out.

Should parse when only Hijri month string is in the format

Should parse when only Hijri month string is in the format

    it('should parse when only Hijri month string is in the format', function() {
      var m = moment('1990 Sha 25', 'YYYY hMMM D')
      m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
      m = moment('1990 Shaโ€™ban 25', 'YYYY hMMMM D')
      m.format('YYYY-MM-DD').should.be.equal('1990-03-25')
    })

Add month wrong date

Sometimes changing month returns wrong date. It happens only if current date is first day in month.

moment.format("iYYYY/iMM/iDD"); // "1438/05/01"
moment.iMonth(5);
moment.format("iYYYY/iMM/iDD"); // "1438/06/29"

Next same event is in 1441

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.