Giter Site home page Giter Site logo

jalaliday's People

Contributors

alimo avatar dependabot[bot] avatar farnabaz avatar farzadso avatar mpourismaiel avatar rezahaidari avatar sasanfarrokh 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

jalaliday's Issues

Computational mistake in converting dates

Please consider the sample:

import dayjs from 'dayjs';
import jalaliday from 'jalaliday';

dayjs.extend(jalaliday);
dayjs.calendar('jalali');

const date = dayjs('1367/02/23', { jalali: true })
const gregory = date.calendar('gregory')
const jalaliDate = date.calendar('jalali');

// Should be 1367/02/23, but is 1367/1/23
console.log(jalaliDate.year() + "/" + jalaliDate.month() +"/"+ jalaliDate.date()); 

 // Should be 1988/05/13, but is 1988/4/13
console.log(gregory.year() + "/" + gregory.month() +"/"+ gregory.date());

This library calculates the conversion of dates incorrectly.

`$set`: Incorrect date update order

In the $set method, the $d property is being updated in this order:

  1. setDate
  2. setMonth
  3. setFullYear

It causes unexpected results in certain cases like this one:

// 2019-11-01
dayjs('1398-08-10', { jalali: true })
  .calendar('jalali')
  .date(9)

The results should be 1398-08-09 but it becomes 1398-07-09. This happens because setDate is called first. Which depends on the current month value and if the given date exceeds the limit of that month, it goes to the next one.

We should reverse the order so that setDate can be aware of the new month value.

Wrong Date of Month

Date of month is wrong in some months

Example for Bahman (1399/11/11):

const date = dayjs().calendar('jalali').locale('fa');
console.log('days =', date.daysInMonth());
for (let i = 1; i <= date.daysInMonth(); i++) {
    console.log('day ' + (i < 10 ? '0' : '') + i + 'th = ' + date.format('DD'));
}

Output:

jdb

Day.js updates reminder in 1.8.9

Hi there,

Just a quick reminder that there are two changes in 1.8.9 to our developers.

  1. Date wrapper Utils.wrapper could be overridden in the plugin.

  2. The name of Utiles[*] has been changed to a shorter name in order to reduce the package size.

Cheers.

Problem associated with leap year

Hi,
I found out that this library uses an incorrect method for calculating leap years,
As an example:
This library shows Esfand month 1403 as 29 days, which is actually a 30-day month.
Additionally, I checked the jalaali-js library and found that it is calculating leap years correctly.

Demo:
https://js-r3ebqv.stackblitz.io

Correct:
image

Note:

List of leap years (problem is with the leap before the five-year leap)
As an example, the year 1408 is a five-year leap, and the leap before this year is 1403. or the year 1441 is a five-year leap, and the leap before this year is 1436.
There is no support for five-year leap years in this plugin, and all leap years are based on four-year leap years.

KabiseShamsi1206-1498-new.pdf

اشکال در تنظیم ماه

وقتی ماه رو تنظیم میکنم برای ماه 12 دچار اشکال میشه.
`
dayjs().calendar('jalali').locale('fa').month(11).format('MMMM'); // فروردین
dayjs().calendar('jalali').locale('fa').month(0).format('MMMM'); // فروردین

dayjs().calendar('jalali').locale('fa').date(1).month(11).format('MMMM'); // اسفند
`

add more info

Hello @pi0
Please add more doc for jalaliday
And
Do not be tired ....

multi extend problem

when I try to use jalaliday in a specific component I realize it converts my Jalali year 1399 to gregorian 3263 instead of 2020.
as I check more I find out its a combination of webpack and your library problem.
when someone import jalalidate in multiple modules in one special hierarchy and extend the original dayjs this library keep adding extra year in date convert process for example if I use this:

import dayjs from 'dayjs';
import jalaliday from 'jalaliday';
dayjs.extend(jalaliday);
dayjs.extend(jalaliday);
dayjs.extend(jalaliday);

the final result of dayjs(1399-08-08, { jalali: true }); will be 4505
as you add more extend it add 621 years to the resulting year
3263->3884->4505->....
i think there must be a solution that multiple extend won't result in wrong date convert

convert jalali date to gregor date

hi,
When I want to change the date, the date is converted as follows and the same jalali date is returned

1400/05/07 => Thu May 08 1400 00:00:00 GMT+0325 (Iran Daylight Time)

const date = "1400/05/07"
dayjs(date ).calendar("gregory").locale("en")

Typescript Support

Thanks for this lib.
but it seems there isn't any type definition for typescript types because when I use dayjs.calendar(...):

Property 'calendar' does not exist on type 'typeof import(".../node_modules/dayjs/index.d.ts")'.

I think you should extend the default dayjs's type definitions.

Day manipulation is broken

Day manipulation (add and subtract) methods don't work properly after extension. They reset the date to 1970-01-01.

I've created a sandbox to reproduce the issue here.

Version: 2.2.2

Gives back wrong date

When I pass 2025/03/20, It gives back "1404/1/1" and it's wrong. It should return "1403/12/30"

مشکل ساعت سال ۱۴۰۲ ایران

امسال با توجه به اینکه ساعت را عقب نکشیدن ساعت خروجی عبارت زیر اشتباه بر می گردد.

dayjs(2023-04-10T10:19:56+0430).calendar('jalali').locale('fa').format('HH:mm - YYYY/MM/DD')
نتیجه
09:19 - 1402/01/21

Wrong list of months

Currently what you get out of months() method is dependant on locale which is wrong.
It should depend on calendar, and locale should only define the language:

dayjs.locale('fa')
console.log(dayjs.calendar('jalali').months())
// outputs: ['فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند']
// Correct!
console.log(dayjs.months())
// outputs: ['فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند']
// Wrong! It should be ژانویه فوریه مارچ etc.

dayjs.locale('en')
console.log(dayjs.calendar('jalali').months())
// outputs: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
// Wrong! It should be Farvardin, Ordibehesht, etc.
console.log(dayjs.months())
// outputs: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
// Correct!

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.