
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 xod/datetime/datetime.
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.
datetime node 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-seconds node shifts the date by adding some number of seconds.format-timestamp node 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”.
format-timestamp with the unpack-datetime node.am-pm node and link it with the HOUR output.if-else node, link it with AM output and bind strings: “am” for T and “pm” for F.concat nodes as it is inside the format-timestamp node, 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”.