craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.26k stars 634 forks source link

[FR] show dates in other calendar format #5000

Closed vnali closed 3 years ago

vnali commented 5 years ago

Description

we use a different calendar type than Gregorian in Iran https://en.wikipedia.org/wiki/Iranian_calendars usually in custom twig templates we can use twig extension and we can convert Gregorian date to a Persian date with code like this:

$intl=new IntlDateFormatter('fa_IR@calendar=persian', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL, 'yyyy/MM/dd HH:mm');
$persian_date = $intl->format($date);

so we convert date like 2019/09/26 to Persian format like 1398/07/04

but in pages like http://craft.samplesite/admin/entries, we have Post Date and craft shows it in Gregorian format like 2019/09/26 and i think this is good to idea to show column date in Persian calendar system like 1398/07/04 - maybe if user language is set to Persian or maybe if there is a calendar type per user and it is set to Persian calendar-

possible solution: it seems Yii2 support different calendar types: https://github.com/yiisoft/yii2/commit/cdb7d84fea5c502b17bffa639d69108cead27a3f so i tried to add

'locale' => 'fa_IR@calendar=persian',
'calendar' => \IntlDateFormatter::TRADITIONAL, 

to https://github.com/craftcms/cms/blob/develop/src/config/locales/fa.php

but it seems craft ignores calendar type and generate date column in Gregorian anyway.

is it possible to show dates in other calendar format for columns like post date or expiry date?

vnali commented 5 years ago

i saw a commit about this by you @brandonkelly on yii2 repo. could we possibly have this in near future?

brandonkelly commented 5 years ago

@vnali Yeah I’m working on it for 3.4.

brandonkelly commented 4 years ago

Pushing this back to 4.0, because it is going to introduce breaking changes.