Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ReportDateTimeAttribute.cs
1using System;
2using System.Xml;
3using Waher.Content;
5
7{
12 {
18 public ReportDateTimeAttribute(XmlElement Xml, string AttributeName)
19 : base(Xml, AttributeName)
20 {
21 }
22
28 public override DateTime ParseValue(string s)
29 {
30 if (XML.TryParse(s, out DateTime Value))
31 return Value;
32 else if (CommonTypes.TryParseRfc822(s, out DateTimeOffset Value2))
33 return Value2.DateTime;
34 else if (DateTime.TryParse(s, out Value))
35 return Value;
36 else
37 throw new ArgumentException("Invalid DateTime value: " + s, nameof(s));
38 }
39 }
40}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:15
static bool TryParseRfc822(string s, out DateTimeOffset Value)
Parses a date and time value encoded according to RFC 822, §5.
Definition: CommonTypes.cs:172
Helps with common XML-related tasks.
Definition: XML.cs:21
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:892
Abstract base class for report attributes.
override DateTime ParseValue(string s)
Parses a string representation of a value.
ReportDateTimeAttribute(XmlElement Xml, string AttributeName)
Report DateTime attribute.