+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Arabic site News Listing to show date in Gregorian

Arabic site News Listing to show date in Gregorian

2 posts, 0 answered
  1. Paul
    Paul avatar
    14 posts
    Registered:
    10 Mar 2012
    31 Jul
    Link to this post
    News listing plugin on Arabic site is showing publication date in Hijri format. I want it to be in Gregorian. Can anyone help?
  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    13 Aug in reply to Paul
    Link to this post

    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")

     

2 posts, 0 answered