Time Conversion - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Requests (/Forum-Script-Requests) +--- Thread: Time Conversion (/Thread-Time-Conversion) |
Time Conversion - mlyon83 - 05-17-2013 02:43 AM Does anyone have or want to write a function to convert seconds from a .TAG variable into Weeks, Days, Hours, Minutes, and Seconds? It would say something like: SRC.SYSMESSAGE @00 3 Weeks, 14 days, 19 Hours, 41 Minutes, and 12 Seconds. ///Conversion drawn from TAG value in seconds. RE: Time Conversion - Mordaunt - 05-17-2013 04:53 AM It's just simple math.... TAG = secs /60 = mins /60/60 = hours /60/60/24 = days /60/60/24/7 = weeks RE: Time Conversion - mlyon83 - 05-17-2013 05:25 AM (05-17-2013 04:53 AM)Mordaunt Wrote: It's just simple math.... Mordaunt, I'm aware, but I'm horrible at math. Thanks for the numbers. RE: Time Conversion - Gil Amarth - 05-17-2013 06:26 PM It´s a bad thing to be a scripter bad in maths. xD If you don´t mind in spanish: Code: [FUNCTION F_TIEMPO_FORMATO] Code: [FUNCTION f_division_resto] // (DIVIDENDO, DIVISOR); Devuelve (RESTO) It returns only days, hours, minutes and seconds, but you can tweak it to give you weeks and months, if you want. RE: Time Conversion - mlyon83 - 05-18-2013 12:22 AM (05-17-2013 06:26 PM)Gil Amarth Wrote: It´s a bad thing to be a scripter bad in maths. xD Wow, thank you much. Good thing I never got started on this myself. I'll run it through Google Translator. RE: Time Conversion - mlyon83 - 05-18-2013 01:55 AM Now if you can just define the following, I'll be set: - DIAS - RESTO - HORAS - NUMERO_VUELTAS - REDUCIDO - VUELTAS_RESTO rofl ;X RE: Time Conversion - Gil Amarth - 05-18-2013 05:51 AM The script is very simple, 1 day it´s 86400 seconds, so you have to divide the the total amount of seconds to how many seconds a day has. Then you have to calculate the rest of the division, f_division_resto does that. It´s only maths. With the rest you repeat the operation, 1 hour has 3600 seconds, and repeat. If you want months, and weeks. Code: [FUNCTION F_FORMAT_TIME] Code: [FUNCTION f_division_rest] // (DIVIDEND, DIVISOR); Returns (REST) Then, you can use F_FORMAT_TIME <TAG.TIME>, and voilá. RE: Time Conversion - Rizz - 05-19-2013 03:31 AM You should use the Julian Date time format, it's the best format to manage time bcuz you can literally sum and subtract a date (like 18/05/2013 19:31) and get the right result. |