Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

OffSet Time zone -Fail

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

OffSet Time zone -Fail

Post by joysprod » 20 Aug 2014, 16:13

Is there an easy way using the Date & Time node, Covert to Text and an expression node to offset the system time by a number of hours? I just cant figure it!

Have been trying to create a series of clocks each showing a different time zone.

Regards

Peter

chriss0212
Posts: 666
Joined: 18 Jan 2012, 20:56
Location: wuppertal
Contact:

Re: OffSet Time zone -Fail

Post by chriss0212 » 20 Aug 2014, 16:29

do you need just the time or the date also?

if just the time...you get everything you need out of the dateTime node...and just need to ad the offset...of course with a modulo function

greetz

christian

User avatar
Daniel Willer
Posts: 309
Joined: 06 Jan 2012, 18:12

Re: OffSet Time zone -Fail

Post by Daniel Willer » 21 Aug 2014, 08:36

There are several DateTime Methods in .Net you can use inside a little Script or even an expression.
Check http://msdn.microsoft.com for further info.

D

joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

Re: OffSet Time zone -Fail

Post by joysprod » 25 Aug 2014, 19:03

Hi Chris & Daniel

Thanks for that. Yes I have that working OK by taking the hours and minutes as separate items from the DateTime node and + or - the hours with the modulo working fine.

What I was trying to do, is what Daniel mentioned in the next post buy using an expression and DateTime AddHours. I can see loads of examples that would work in a script but cant get it working inside an expression. Just cant get the syntax right to allow it to compile correctly. Ventuz Help in this case is No Help as no examples.

Regards

Peter

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: OffSet Time zone -Fail

Post by Chris » 25 Aug 2014, 19:12

quick example, you just need to add the string outputs to the script. (i.e 'istHour' etc)
you can use any local system time zones.

chris

Code: Select all

	DateTime dt = DateTime.Now;
		
		
 		var ist = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, TimeZoneInfo.Local.Id, "India Standard Time");
		istHour = ist.Hour.ToString();
		
		var pt = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, TimeZoneInfo.Local.Id, "Pacific Standard Time");
		ptHour = pt.Hour.ToString();
		
		var ct = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, TimeZoneInfo.Local.Id, "Central Standard Time");
		ctHour = ct.Hour.ToString();
		

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: OffSet Time zone -Fail

Post by Chris » 25 Aug 2014, 19:15

forgot to mention this just gives you the hours as an output not min and secs but thats all your after i guess ;)

chris

User avatar
Daniel Willer
Posts: 309
Joined: 06 Jan 2012, 18:12

Re: OffSet Time zone -Fail

Post by Daniel Willer » 26 Aug 2014, 08:49

It is a little tricky to do it in a expression.
Because the expression nodes does not have the type DateTime you have to parse the value inside the expression to DateTime, add the hours and convert back to a string.
Just take a string expresion node and add the follwoing expression

Code: Select all

DateTime.Parse(A, System.Globalization.CultureInfo.InvariantCulture).AddHours(2).ToString("hh")

joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

Re: OffSet Time zone -Fail

Post by joysprod » 26 Aug 2014, 14:59

Thank you both for most elegant solutions.

Daniel, each time I encounter such a concise and beautiful solution I know I have so many things to learn in Ventuz.

Regards

Peter

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: OffSet Time zone -Fail

Post by Chris » 27 Aug 2014, 10:02

Agreed ;)

Post Reply