timecalc() »»» Zeitangaben beliebig umrechnen & ausgeben
Verfasst: 16.10.2007 20:38
- (reserviert für den aktuellsten Code aus Gründen der Übersichtlichkeit)
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
Procedure.s timecalc(mask$, time.q) ; %yy %dd %hh %ii %ss %ms
If FindString(mask$, "%yy", 1)
Protected yy.l=time/31536000000
time-yy*31536000000
mask$=ReplaceString(mask$, "%yy", Str(yy))
EndIf
; Month cannot be calculated, because a month can have 28-31 days
If FindString(mask$, "%dd", 1)
Protected dd.l=time/86400000
time-dd*86400000
mask$=ReplaceString(mask$, "%dd", Str(dd))
EndIf
If FindString(mask$, "%hh", 1)
Protected hh.q=time/3600000
time-hh*3600000
mask$=ReplaceString(mask$, "%hh", Str(hh))
EndIf
If FindString(mask$, "%ii", 1)
Protected ii.q=time/60000
time-ii*60000
mask$=ReplaceString(mask$, "%ii", Str(ii))
EndIf
If FindString(mask$, "%ss", 1)
Protected ss.q=time/1000
time-ss*1000
mask$=ReplaceString(mask$, "%ss", Str(ss))
EndIf
If FindString(mask$, "%ms", 1)
mask$=ReplaceString(mask$, "%ms", Str(time))
EndIf
ProcedureReturn mask$
EndProcedure
Debug timecalc("Kurz: %yyy %ddd %hhh %iim %sss %msms", 34041598234)
Debug timecalc("Normal: %yy years %dd days %hh hours %ii minutes %ss seconds %ms milliseconds", 34041598234)
Debug timecalc("Abgekürzt: %yy yrs %dd days %hh hrs %ii mins %ss sec %ms msec", 34041598234)
Debug timecalc("Mathematisch: %yyy %ddd %hh:%ii'%ss''%ms'''", 34041598234)