FatulM / shamsi_date

A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian, Jalaali, شمسی or خورشیدی) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi or میلادی) date and times.
https://pub.dev/packages/shamsi_date
BSD 3-Clause "New" or "Revised" License
78 stars 10 forks source link

Convert To Jalali directly from '2021-02-10T17:42:01' #9

Closed AliEasy closed 3 years ago

AliEasy commented 3 years ago

Hi To get Gregorian from DateTime I have to use DateTime date = DateTime.parse(dateString); first and then use Jalali.fromDateTime(dateTime);

It will be easier to have a shortcut for that.

FatulM commented 3 years ago

Hi, The problem is that shamsi_date does not store time data, so does not have time zones and ... For example in one part of world we may be in some day and in other part in another day ... And shamsi_date does not have any preference in time zones. So converting from DateTime will loose some information ... This approach I think is misleading. What's your opinion ?

I'll add extension functions for DateTime, so yo can simply write: DateTime.parse(string).toGregorian() Or DateTime.parse(string). toJalali()

@AliEasy

FatulM commented 3 years ago

And there is also a plan to add efficient parsers for shamsi_date. Which does not need time zone and time data ... But it is in its very early stages ... And I have lots of confusion about that too 😅 I'll be appreciated if you give me any comments ... @AliEasy

AliEasy commented 3 years ago

Yeah I noticed it today when I was trying to get DateTime from toDateTime() :)

But in my case I need only the date not the time so I guess sth like DateTime.parse(string).toJalali() would do the job for now.

FatulM commented 3 years ago

Hi, I have added extension methods for DateTime on master branch. I'll be appreciated if you check them out to see if it have what you needed. Sorry for being so late ... @AliEasy

FatulM commented 3 years ago

Hi, I'll close this issue. If you feel your problem is not solved, please reopen this issue. @AliEasy