Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert seconds into days,hours,minutes and seconds
Message
From
30/03/2004 22:49:12
 
 
To
30/03/2004 21:19:26
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00891059
Message ID:
00891070
Views:
25
FUNCTION sec2time
	PARAMETERS m.lnSec2Convert,m.showmorethan24hrs
	*** converts seconds since midnight to time () format
	*** useful for adding seconds to a time
	PRIVATE m.lcStHours,m.lcStMinutes,m.lcStSeconds,m.lcDay
	m.lcDay = ""
	IF TYPE("m.lnSec2Convert") <> "N"
		m.lnSec2Convert = SECONDS()
	ENDIF
	IF m.lnSec2Convert < 0 and pcount() = 1
		m.s2tzz = iif(mod(abs(m.lnSec2Convert),86400)= 0,0,1)+int(abs(m.lnSec2Convert)/86400)
		m.lnSec2Convert = m.lnSec2Convert+((m.s2tzz*24)*3600)
		m.lcDay = " *** -"+alltrim(str(m.s2tzz))+" days "
	ENDIF
	m.lcStHours = INT(m.lnSec2Convert/3600)
	m.lcStMinutes = INT(MOD(m.lnSec2Convert,3600)/60)
	m.lcStSeconds = INT(MOD(MOD(m.lnSec2Convert,3600),60))
	if pcount() = 1
	IF m.lcStHours > 24 OR (m.lcStHours >=24 and m.lcStMinutes+m.lcStSeconds > 0)
		*** seconds passed is more than 24 hour - return number of days+time
		m.lcDay = " *** +"+alltrim(str(int(m.lcStHours/24)))+" days "
		m.lcStHours = mod(m.lcStHours,24)
	ENDIF
    endif
	RETURN PADL(ALLTRIM(STR(m.lcStHours)),max(len(ALLTRIM(STR(m.lcStHours))),2),"0")+":"+;
		PADL(ALLTRIM(STR(m.lcStMinutes)),2,"0")+":"+;
		PADL(ALLTRIM(STR(m.lcStSeconds)),2,"0")+m.lcDay
Previous
Reply
Map
View

Click here to load this message in the networking platform