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

Forums / Developing with Sitefinity / SiteFinity 3.7 SP 1 Problem with custom RSS dates

SiteFinity 3.7 SP 1 Problem with custom RSS dates

2 posts, 0 answered
  1. Ben Wright
    Ben Wright avatar
    2 posts
    Registered:
    06 Apr 2006
    24 Sep 2010
    Link to this post
    The feed serviced by GetRssItems() below is working, however the dates are correct in GetRssItems() but are shifted back to the previous day in the actual feed. In all cases, the correct date is 12:01 am on a given day and the output date is 5:00pm on the previous day. Please see below. Is this a bug or am I missing something?

    public IList<RssItem> GetRssItems(System.Collections.Specialized.NameValueCollection query)  
            {
                string path;
                List<RssItem> feed = new List<RssItem>();  
                RssItem item;

                // Get all articles
                ArticlesManager articlesMgr = new ArticlesManager(this._articleProvider);
                IList articles = articlesMgr.Content.GetContent();
                
                // Get all issues of the right publication type
                PublicationsManager pubsMgr = new PublicationsManager((string)null);
                List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
                filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "PublicationType", this._publicationType));
                IList pubs = pubsMgr.Content.GetContent("PublishDate DESC", filter.ToArray());

                DateTime publishDate;
                Guid pubID;
                string articleParentID;

                // Only send articles that matches the right publications (issues)
                foreach (IContent publication in pubs)
                {
                    // get publication's date and guid
                    publishDate = (DateTime) publication.GetMetaData("PublishDate");
                    pubID = publication.ID;

                    foreach (IContent article in articles)
                    {
                        articleParentID = (string)article.GetMetaData("Publication");
                        if ((string)articleParentID != pubID.ToString())
                            continue;

                        item = new RssItem();

                        if (!this._articleUrl.StartsWith("http://"))
                            path = String.Concat("http://", HttpContext.Current.Request.ServerVariables["SERVER_NAME"], this._articleUrl);
                        else
                            path = this._articleUrl;

                        int idx = path.LastIndexOf('.');
                        if (idx > -1)
                            path = path.Substring(0, idx);

                        IUrlRewriterService articlesRewriter = articlesMgr.Content.GetUrlRewriterService(article);
                        string articleRef = articlesRewriter.GetItemUrl(article) + ".aspx";
                        item.Link = new Uri(String.Concat(path, articleRef), UriKind.Absolute);
                        
                        if (!String.IsNullOrEmpty((string)article.GetMetaData("Author")))
                            item.Author = (string)article.GetMetaData("Author");
                        else
                            item.Author = "Unknown";

                        item.Comments = new Uri(path).ToString();

                        item.PubDate = publishDate;

    *** publishDate is the correct date and item.PubDate is also correct after assignment ***

                        item.Title = article.GetMetaData("Title") as string;

                        switch (this._syndicationType)
                        {
                            case SyndicationType.Full:
                                item.Description = article.Content.ToString();
                                break;
                            case SyndicationType.Summary:
                                item.Description = this.CreatePostSummary(article.Content.ToString());
                                break;
                            case SyndicationType.TitleOnly:
                                item.Description = item.Title;
                                break;
                        }

                        item.Guid = new RssGuid(article.ID.ToString(), false);

                        if (feed.Count < this._articleCount)
                            feed.Add(item);
                        else
                            break;
                    }
                }
                return feed;  
            }
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    27 Sep 2010
    Link to this post
    Hello Ben Wright,

    It looks like you need to convert the data format to UTC. I created a very simple provider to test this behavior and all dates are set correctly at my end. I attached a sample short video for you.

    public class ExtendedRssChanelProvider : Telerik.News.Rss.RssChannelProvider
    {
        public override string ContentItemKey
        {
            get
            {
                return NewsManager.NewsItemKey;
            }
        }
     
        public override string ContentProviderKey
        {
            get
            {
                return NewsManager.NewsProviderKey;
            }
        }
     
        public override string Name
        {
            get
            {
                return "CustomNewsProvider";
            }
        }
     
        public override IList<Telerik.Rss.RssItem> GetRssItems(System.Collections.Specialized.NameValueCollection query)
        {
            var newList = new List<Telerik.Rss.RssItem>();
            var items = base.GetRssItems(query).Cast<Telerik.Rss.RssItem>().Take(2);
            foreach (Telerik.Rss.RssItem i in items)
            {
                i.PubDate = DateTime.Now;
                newList.Add(i);
            }
            return newList;
        }
      
    }


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered