Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

sec_2_x

Uploader:MitgliedThe_Muh
Datum/Zeit:21.08.2008 16:01:24

declare function sec_2_x(byref Seconds as double) as string

function sec_2_x(byref Seconds as double) as string
    dim minutes as double
    dim hours as integer
    dim days as integer
    dim months as integer
    dim years as integer
    dim decade as integer
    dim stamp as string

    if seconds > 59 then
        minutes = int(seconds / 60)
        seconds -= minutes * 60
    end if
    if minutes > 59 then
        hours = int(minutes / 60)
        minutes -= hours * 60
    end if
    if hours >= 24 then
        days = int(hours / 24)
        hours -= days * 24
    end if
    if days >= 365 then
        years = int(days / 365)
        days -= years * 365
    end if
    if days > 31 then
        months = int(days / 30)
        days -= months * 30
    end if
    if years >= 10 then
        decade = int(years / 10)
        years -= decade * 10
    end if

    if decade <> 0 then
        stamp = stamp + str(decade) + " decade(s) "
    end if
    if years <> 0 then
        stamp = stamp + str(years) + " year(s) "
    end if
    if months <> 0 then
        stamp = stamp + str(months) + " months(s) "
    end if
    if days <> 0 then
        stamp = stamp + str(days) + " day(s) "
    end if
    if hours <> 0 then
        stamp = stamp + str(hours) + " hours(s) "
    end if
    if minutes <> 0 then
        stamp = stamp + str(minutes) + " minutes(s) "
    end if
    if seconds <> 0 then
        stamp = stamp + str(seconds) + " second(s)"
    end if

    return stamp
end function

print sec_2_x(3601)