public void FormatEmpty() { // action var tryFormatResult = Rfc3339TimestampFormatter.TryFormatTimestampAsString(null, out _); // assert Assert.False(tryFormatResult); }
public void FormatInputs(string expectedOutput, DateTimeOffset input) { // action var tryFormatResult = Rfc3339TimestampFormatter.TryFormatTimestampAsString(input, out var actualOutput); // assert Assert.True(tryFormatResult); Assert.Equal(expectedOutput, actualOutput); }
private static bool TryFormatAtom10TimestampRequired(DateTimeOffset?timestampToFormat, XName name, out XElement timestampElement) { string timestampString; if (timestampToFormat == null) { timestampString = ""; } else if (!Rfc3339TimestampFormatter.TryFormatTimestampAsString(timestampToFormat.Value, out timestampString)) { timestampString = ""; } timestampElement = new XElement(name, timestampString); return(true); }
private static bool TryFormatAtom10TimestampOptional(DateTimeOffset?timestampToFormat, XName name, out XElement timestampElement) { timestampElement = default; if (timestampToFormat == null) { return(false); } if (!Rfc3339TimestampFormatter.TryFormatTimestampAsString(timestampToFormat.Value, out var timestampString)) { return(false); } timestampElement = new XElement(name, timestampString); return(true); }
private static bool TryFormatJsonFeedOptionalTimestampProperty(string propertyName, DateTimeOffset?timestampToFormat, out JProperty timestampProperty) { timestampProperty = default; if (timestampToFormat == null) { return(false); } if (!Rfc3339TimestampFormatter.TryFormatTimestampAsString(timestampToFormat, out var formattedTimestamp)) { return(false); } timestampProperty = new JProperty(propertyName, new JValue(formattedTimestamp)); return(true); }
private static bool TryFormatRss10SyndicationUpdateBase(DateTimeOffset?valueToFormat, XNamespaceAliasSet namespaceAliases, out XElement element) { element = default; if (valueToFormat == null) { return(false); } if (!Rfc3339TimestampFormatter.TryFormatTimestampAsString(valueToFormat.Value, out var valueString)) { return(false); } namespaceAliases.EnsureNamespaceAlias(Rss10SyndicationExtensionConstants.NamespaceAlias, Rss10SyndicationExtensionConstants.Namespace); element = new XElement(Rss10SyndicationExtensionConstants.Namespace + "updateBase") { Value = valueString }; return(true); }
private static bool TryFormatDublinCoreTimestamp(DateTimeOffset?valueToFormat, string elementName, XNamespaceAliasSet namespaceAliases, out XElement element) { element = default; if (valueToFormat == null) { return(false); } if (!Rfc3339TimestampFormatter.TryFormatTimestampAsString(valueToFormat.Value, out var valueString)) { return(false); } namespaceAliases.EnsureNamespaceAlias(DublinCoreExtensionConstants.NamespaceAlias, DublinCoreExtensionConstants.Namespace); element = new XElement(DublinCoreExtensionConstants.Namespace + elementName) { Value = valueString }; return(true); }