question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Persian calendar year and month view

See original GitHub issue

Environment

Tech Version
@material-ui/pickers latest
material-ui 4.0.0-beta.2
React 16.8.6
Browser chrome
Peer library @date-io/jalaali: “1.3.5”, moment-jalaali: “0.8.3”

Expected behavior

expected month name to be in jalaali format something like فروردین اردیبهشت خرداد ...

Actual behavior

month name are not in jalaali format and after choose one, year may change because of jalaali date time difference

Live example

https://codesandbox.io/s/materialuipickersusagedemo-6tqti?fontsize=14

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
pesehrcommented, Jun 9, 2019

@mohsensaremi use this:

    JalaliUtils.prototype.getDatePickerHeaderText = function (date) {
      return date.format("ddd, jD jMMMM");
    };
2reactions
pesehrcommented, Jun 9, 2019

Dear @mohsensaremi This is a problem in date-io/jalaali library. You can solve that temporary by overriding these methods.

import JalaliUtils from "@date-io/jalaali";

JalaliUtils.prototype.getMonthArray = function (date) {
      date = jMoment(date)
      var firstMonth = date.clone().startOf("jyear");
      var monthArray = [firstMonth];
      while (monthArray.length < 12) {
        var prevMonth = monthArray[monthArray.length - 1];
        monthArray.push(this.getNextMonth(prevMonth));
      }
      return monthArray;
    }; 
    JalaliUtils.prototype.format = function (date, formatString) {
      if (formatString === 'MMM')
        formatString = 'jMMMM'
      return date.format(formatString);
    };
   JalaliUtils.prototype.getMonth = function (date) {
      date = jMoment(date)
      let months = JalaliUtils.prototype.getMonthArray(date)
      for (let i = 0; i < months.length; i++) {
        if (months[i].format('jMMMM') === date.format('jMMMM')) {
          return i;
        }
      }
      return date.get("month");
    };
   JalaliUtils.prototype.setMonth = function (date, count) {
      date = jMoment(date)
      return date.clone().jMonth(count);
    };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Iranian calendars - Wikipedia
Old Persian calendarEdit ; 2, April–May, Θūravāhara, Turmar, Possibly "(Month of) strong spring" ; 3, May–June, Θāigraciš, Sākurriziš, "Garlic-collecting month" ...
Read more >
Persian Solar Hijri calendar - Time and Date
A year in the Solar Hijri calendar is divided into 12 months of varying lengths. The first 6 months have 31 days, and...
Read more >
Persian/Phrasebook/Seasons and Months - Wikibooks
Persian Pronunciation English Zodiac sign بهار bahâr spring فروردین farvardin (31 days) 21 Mar. ‑ 20 Apr. Aries اردیبهشت ordibehešt (31 days) 21 Apr. ‑ 21...
Read more >
Iranian Calendar to Western Calculator - keisan
Iranian calendar (Persian calendar) is a solar calendar that New Year's Day is Vernal Equinox.Previous six months consists of 31 days, five months...
Read more >
The Iranian Calendar is Perfect... And Here's Why
From days in a month to seasonal celebrations, find out the specifics of the Iranian calendar and what makes it so logical and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found