[SOLVED] Local system time?

Me… again. Missing a node for system time, i would appreciate any hints to get the system time (maybe in a string format?)

.

There is a node to turn a string to float but not vice-versa. Would love to build a Nixie clock in Armory3D.

Hi, I don’t think there is a node to get current system time. What is possible as a workaround is to use a small Haxe script to get the time and use logic nodes to read it.

This requires a NodeTree and a Haxe script. In my case, both are applied to the Scene.

The NodeTree:

The Haxe script:

package arm;

class MyTrait extends iron.Trait {

	public var sysTime(get, default): String;

	public function get_sysTime() {
		return Date.now().toString();
	}
	public function new() {
		super();
	}
}

With this, you can get the current date and time as a string in the logic node tree. Aditionally, if required, with slight modifications to the Haxe script, you can get just the date or just the time or either as a float.

You can use “Concatenate String” node to pass in a float and get out a string.

Hope this helps.

2 Likes

Thank you so much. That solves a few problems i had to get values out of Haxe script.IMHO it can also be seen as a general example of how to do just that. I think it should be added to examples, because the Call.hx example with Java script mix is (for me) just plain puzzling. This one is a lot clearer.

1 Like

Cool that it works for you!

In my opinion, this is just a work-around for the general problem of running a Haxe script from a logic tree, so I wouldn’t want to make an example out of it. A better general solution would be a new “Call Haxe Function” node, similar to “Call Haxe Static” node which accepts function arguments too. Once that is implemented, it can be added to the examples.

Cheers!

Yes, works like a charm. I was tinkering with the “Call Haxe Static” node on this occasion, but could not figure out the proper input syntax due to a lacking example. As i do not know, whether “Call Haxe Static” can be applied at all for this case i stopped trying. That was the reason for my question and the proposal. Btw. this was the Missing Link for me. Getting values from Haxe script into the node tree. That really boosts my motivation to learn Haxe.

After creating the first draft of the Nixie clock i found that there seems to be no way to adjust for Daylight Saving Time or time zone with Haxe Date.now(). I had to hard code a correction with nodes. So the time will be off one hour after the end of DST. As an automatic DST correction with nodes would become rather bulky, i would be grateful if somebody could point me to a more elegant solution. Live example updated, see in Showcase. Was compiled with mobile option.

Screenshot

EDIT: Just tried it myself from my mobile. Works correctly on Manjaro with correction, but then its plus one hour off on my mobile. Meaning on Android Date.now() delivers the correct value without node correction, but for LINUX it is necessary. How come?

EDIT: Found the culprit. Manjaro system gets time from an NTP server in another time zone. Windows manager plugin corrects it, but Haxe date/ time gets it from system. Hmm, quite a bit untidy. Let´s see how to tidy up. Will re-upload when done.

Solution: Set correct timezone

Example:
timedatectl set-timezone Pacific/Tahiti
see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Then i deleted my node workaround and up scaled the clock (was a bit tiny) Tataa…
See new upload in Showcase.

2 Likes