Arabic site News Listing to show date in Gregorian

Posted by Community Admin on 04-Aug-2018 16:42

Arabic site News Listing to show date in Gregorian

All Replies

Posted by Community Admin on 31-Jul-2016 00:00

News listing plugin on Arabic site is showing publication date in Hijri format. I want it to be in Gregorian. Can anyone help?

Posted by Community Admin on 13-Aug-2016 00:00

Hi Paul. I had the same problem. I just built new extension for ItemViewModel.

public static class ItemViewModelExtension
    
        public static string GetDateTimeGregorianCalendar(this ItemViewModel item, string fieldName, string format)
        
            var date = (DateTime)item.Fields.GetMemberValue(fieldName);
            var culture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.Name);
            GregorianCalendar calendar = new GregorianCalendar();
            culture.DateTimeFormat.Calendar = calendar;
            return date.ToString(format, culture);
        
    

And in Feather widget template i am using 

@item.GetDateTimeGregorianCalendar("PublicationDate", "MMM d, yyyy, HH:mm tt")

instead 

@item.GetDateTime("PublicationDate", "MMM d, yyyy, HH:mm tt")

 

This thread is closed