Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Tz.cs
1using System;
2using System.Text;
4using Waher.Script;
8
10{
15 {
25 {
26 }
27
31 public override string FunctionName => nameof(Tz);
32
40 {
41 if (Argument.AssociatedObjectValue is DateTimeOffset TPO)
42 {
43 if (TPO.Offset == TimeSpan.Zero)
44 return new StringLiteral("Z");
45 else
46 {
47 StringBuilder sb = new StringBuilder();
48
49 if (TPO.Offset < TimeSpan.Zero)
50 sb.Append('-');
51
52 sb.Append(TPO.Offset.Hours.ToString("d2"));
53 sb.Append(':');
54 sb.Append(TPO.Offset.Minutes.ToString("d2"));
55
56 return new StringLiteral(sb.ToString());
57 }
58 }
59 else if (Argument.AssociatedObjectValue is DateTime)
60 return new StringLiteral(string.Empty);
61 else
62 throw new ScriptRuntimeException("Expected a Date and Time value.", this);
63 }
64 }
65}
Abstract base class for functions of one semantic variable.
override IElement EvaluateScalar(ISemanticElement Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Tz.cs:39
Tz(ScriptNode Argument, int Start, int Length, Expression Expression)
Tz(x)
Definition: Tz.cs:23
override string FunctionName
Name of the function
Definition: Tz.cs:31
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
Collection of variables.
Definition: Variables.cs:25
Interface for semantic nodes.
Basic interface for all types of elements.
Definition: IElement.cs:20