In addition to the primitive data types, XOD has more complicated custom types. Custom types can consist of other types or wrap C++ classes.
Consider custom type values like black boxes that can’t do anything on their own. An author of the custom type always puts some nodes which operate on such custom type values. Use these to perform actions on custom type value, query the custom type data, or create and update the custom type values.
On this patch, you see the
datetime node, which takes few numbers and outputs a value of a custom type
This type contains a so-called POSIX timestamp inside. The
xod/datetime library provides nodes to manipulate the
datetime and format it to in arbitrary way.
datetimenode is one of the type constructors. Note that the minimum value is 1st January of the 1970 year. It’s a starting point of the Unix epoch.
add-secondsnode shifts the date by adding some number of seconds.
format-timestampnode outputs the datetime in the default format.
Bind the current time and start the simulation.
^ Add/Subtract hours
Format the same datetime as “24.03.2019 9:47 am”.
am-pmnode and link it with the
if-elsenode, link it with
AMoutput and bind strings: “am” for
Tand “pm” for
concatnodes as it is inside the
format-timestampnode, including the “am”/“pm” suffix feature.
Run the simulation and check it out.
Add or subtract some hours using the
tweak-number node that is already on the patch, to ensure that “am” and “pm” suffix works.
You’ll discover that XOD uses custom types extensivelly. They encapsulate different hardware devices, interfaces, protocols, and so on.
If you want to learn how to implement your custom type, read the guide: “Defining Custom Types”.