Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: alternativee30 on July 09, 2012, 03:06:25 AM

Title: [SOLVED] Time formatting
Post by: alternativee30 on July 09, 2012, 03:06:25 AM
Regarding the following topic..
http://hutonggames.com/playmakerforum/index.php?topic=1711.0#lastPost

I want the user to be able to input a time format and then take that time formatted string and convert it back into seconds.

I can make individual inputs for Hours, Minutes and Seconds and do the math myself but i am wondering if there is a way to reverse the custom action for Seconds to String.
Title: Re: Time formatting
Post by: jeanfabre on July 09, 2012, 04:30:37 AM
Hi,

 look into this:
http://hutonggames.com/playmakerforum/index.php?topic=1047.msg4332#msg4332 (http://hutonggames.com/playmakerforum/index.php?topic=1047.msg4332#msg4332)

this should allow you to get what you want.

bye,

 Jean
Title: Re: Time formatting
Post by: alternativee30 on July 09, 2012, 06:09:37 AM
Hey,

The action works great. Only one thing i cant figure out.

I can get it to find the difference between the format
HH:mm
and
HH:mm


But i cant get it to convert
HH:mm:ss
and
HH:mm:ss
(http://s11.postimage.org/6l5lnxd8z/Screen_Shot_2012_07_09_at_2_53_25_AM.png)
(http://s11.postimage.org/7fs59yl3n/Screen_Shot_2012_07_09_at_3_04_25_AM.png)

With a seconds spot it gives me a invalid format string.
(http://s8.postimage.org/3lf16v4z9/Screen_Shot_2012_07_09_at_2_53_40_AM.png)
Title: Re: Time formatting
Post by: jeanfabre on July 09, 2012, 08:08:11 AM
Hi,

 you'll need to comply with the available format options.

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx (http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx)

If you can't find what you need, can you provide me with the exact output you expect, and I'll give it a go.

 bye,

 Jean
Title: Re: Time formatting
Post by: alternativee30 on July 10, 2012, 05:13:10 AM
I only need to take a string formatted in 00:00:00 for hours, minutes, and seconds and find the difference in time between it and 00:00:00.

So i need the result to be total seconds difference between 00:00:00 and 00:00:60 (my example string)

The float stored for my example would be 60 total seconds difference.
Title: Re: Time formatting
Post by: jeanfabre on July 10, 2012, 12:12:17 PM
hi,

 ok, I see, so if it was 1 minute and 10 seconds you want to show 70 not 00:00:70 right ?

 bye,

 Jean
Title: Re: Time formatting
Post by: alternativee30 on July 10, 2012, 07:26:20 PM
Correct.

im using the stored seconds in the float variable for mathmatical equations then converting the seconds back to an understandable time string in HH:mm:ss.
Title: Re: Time formatting
Post by: jeanfabre on July 11, 2012, 03:58:34 AM
Hi,

ok, got confused by this sorry. It's all working ok for me, see attached, I can use HH:mm:ss fine

if that doesn't work, it's likely that  the start or end date are not complying to that format. they need to be EXACTLY formated, else you will get that exception.

 bye,

 Jean
Title: Re: Time formatting
Post by: alternativee30 on July 11, 2012, 05:10:30 AM
hmm weird it works for me as well when i compare straight in the editor. the problem arises when i try to compare it to a string i have stored from getting the "text" property of a NGUI label.

I will mess with it some more and see if i cant find a solution.
Title: Re: Time formatting
Post by: jeanfabre on July 11, 2012, 05:44:57 AM
hi,

 what exactly is the string you are inputing? Debug it on the console, then you'll know if that matches the format

 bye,

 Jean
Title: Re: Time formatting
Post by: alternativee30 on July 12, 2012, 03:00:13 AM
Doh... facepalm... cant believe it  :-\

it cant be 00:00:60

it has to be 00:01:00
Title: Re: [SOLVED] Time formatting
Post by: mweyna on September 15, 2014, 12:17:14 PM
Can this approach factor in more then just days, to be truely calender accurate?
Title: Re: [SOLVED] Time formatting
Post by: jeanfabre on September 18, 2014, 09:29:45 AM
Hi,

 Yep, with the correct format, it can.

 Bye,

 Jean
Title: Re: [SOLVED] Time formatting
Post by: mweyna on September 18, 2014, 04:07:29 PM
This looks like it'll definitely help solve half my problem. However, it doesn't appear that that Minutes option is working for me, it's setup exactly like the other two that work fine. I've confirmed the format I'm using to add time is correct -

DD.HH:MM:SS

Any ideas?

(http://s7.postimg.org/n0khz1ajf/Time_Error.png)
Title: Re: [SOLVED] Time formatting
Post by: mweyna on September 22, 2014, 02:29:24 AM
Jean?
Title: Re: [SOLVED] Time formatting
Post by: jeanfabre on September 23, 2014, 04:36:32 AM
Hi,

 yes, sorry, huge back log of pending threads :)

d'oh, it's not implement in the code :)

 I have added the action on the ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181).

you can download it here as well. Warning I renamed the file, cause it was clashing with the class name.

GetTimeSpaneBetweenDates (https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/e6d36a6fea9d9d5b7be07c411ef8aa8065fe5f73/Assets/PlayMaker%20Custom%20Actions/Time/GetTimeSpanBetweenDates.cs)


 Bye,

 Jean
Title: Re: [SOLVED] Time formatting
Post by: mweyna on September 23, 2014, 12:20:29 PM
Awesome, thanks sir! I'll give it a whirl later today.
Title: Re: [SOLVED] Time formatting
Post by: mweyna on September 23, 2014, 04:03:09 PM
Works great!