Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ToDateTimeLiteral.cs
1using System;
2using System.Numerics;
3using Waher.Content;
8
10{
15 {
20 : base()
21 {
22 }
23
33 {
34 }
35
45 {
47 }
48
52 public override string FunctionName => DateTimeLiteral.TypeUri;
53
59 public override IElement Convert(object Value)
60 {
61 if (Value is DateTime d)
62 return new DateTimeLiteral(d);
63 else if (Value is DateTimeOffset DTO)
64 return new DateTimeLiteral(DTO.DateTime);
65 else if (Value is string s)
66 {
67 if (XML.TryParse(s, out d))
68 return new DateTimeLiteral(d);
69 }
70
71 d = System.Convert.ToDateTime(Value);
72 return new DateTimeLiteral(d);
73 }
74 }
75}
const string TypeUri
http://www.w3.org/2001/XMLSchema#boolean
Helps with common XML-related tasks.
Definition: XML.cs:19
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:744
Class managing a script expression.
Definition: Expression.cs:39
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
override ScriptNode CreateFunction(ScriptNode Argument, int Start, int Length, Expression Expression)
Creates a function node.
ToDateTimeLiteral(ScriptNode Argument, int Start, int Length, Expression Expression)
Converts a value to a DateTime literal.
override IElement Convert(object Value)
Converts an object to the desired type.
Basic interface for all types of elements.
Definition: IElement.cs:20