BlogEngine.Core.SyndicationGenerator.ToW3CDateTime C# (CSharp) Method

ToW3CDateTime() private static method

Converts the supplied DateTime to its equivalent W3C DateTime string representation.
private static ToW3CDateTime ( System.DateTime utcDateTime ) : string
utcDateTime System.DateTime /// The Coordinated Universal Time (UTC) to convert. ///
return string
        private static string ToW3CDateTime(DateTime utcDateTime)
        {
            var utcOffset = TimeSpan.Zero;
            return (utcDateTime + utcOffset).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture) +
                   FormatW3COffset(utcOffset, ":");
        }

Usage Example

Ejemplo n.º 1
0
        //============================================================
        //	PRIVATE ATOM METHODS
        //============================================================
        #region WriteAtomContent(XmlWriter writer, List<IPublishable> publishables)
        /// <summary>
        /// Writes the Atom feed element information to the specified <see cref="XmlWriter"/> using the supplied collection.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to write channel element information to.</param>
        /// <param name="publishables">The collection of <see cref="IPublishable"/> objects used to generate syndication content.</param>
        /// <param name="title">The title of the ATOM content.</param>
        private void WriteAtomContent(XmlWriter writer, List <IPublishable> publishables, string title)
        {
            //------------------------------------------------------------
            //	Write required feed elements
            //------------------------------------------------------------
            writer.WriteElementString("id", Utils.AbsoluteWebRoot.ToString());
            writer.WriteElementString("title", title);
            writer.WriteElementString("updated", (publishables.Count > 0) ? SyndicationGenerator.ToW3CDateTime(publishables[0].DateModified.ToUniversalTime()) : SyndicationGenerator.ToW3CDateTime(DateTime.UtcNow));

            //------------------------------------------------------------
            //	Write recommended feed elements
            //------------------------------------------------------------
            writer.WriteStartElement("link");
            writer.WriteAttributeString("href", Utils.AbsoluteWebRoot.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "self");
            writer.WriteAttributeString("href", Utils.AbsoluteWebRoot + "syndication.axd?format=atom");
            writer.WriteEndElement();

            //writer.WriteStartElement("link");
            //writer.WriteAttributeString("rel", "alternate");
            //writer.WriteAttributeString("href", Utils.FeedUrl.ToString());
            //writer.WriteEndElement();

            //------------------------------------------------------------
            //	Write optional feed elements
            //------------------------------------------------------------
            writer.WriteElementString("subtitle", this.Settings.Description);

            //------------------------------------------------------------
            //	Write common/shared feed elements
            //------------------------------------------------------------
            this.WriteAtomContentCommonElements(writer);

            foreach (IPublishable publishable in publishables)
            {
                //------------------------------------------------------------
                //	Skip publishable content if it is not visible
                //------------------------------------------------------------
                if (!publishable.IsVisible)
                {
                    continue;
                }

                //------------------------------------------------------------
                //	Write <entry> element for publishable content
                //------------------------------------------------------------
                WriteAtomEntry(writer, publishable);
            }
        }
All Usage Examples Of BlogEngine.Core.SyndicationGenerator::ToW3CDateTime