Hi
I have a requirement as below:
I give input to my as seconds
datetimefromunixtime ( integer(8) seconds )
-It should return a datetime from a count of seconds since 1970 (UNIX time).
My code:
temp=0
flag=0
if ((TimeInSec>=-4 AND TimeInSec<0) )
then
Ans = " 01 JAN 1970 12:00:00am"
end
if (flag =0 AND TimeInSec>=0)
then
Noofdays=TimeInSec/86400 + 732
RemainingTime=(MOD(TimeInSec,86400))
F1=oconv(Noofdays,"D")
F2=oconv(RemainingTime,"MTHS")
Ans=" " : F1 :" " : F2
end
else
if (flag =0 AND TimeInSec<-4)
then
z: temp = temp+1
TimeInSec = TimeInSec+86400
if(TimeInSec<0) then goto z
Noofdays=TimeInSec/86400 + 732
Noofdays = Noofdays - temp
RemainingTime=(MOD(TimeInSec,86400))
F1=oconv(Noofdays,"D")
if (RemainingTime < 86400 AND RemainingTime > 86395 ) then F2 = "12:00:00am" else F2=oconv(RemainingTime,"MTHS")
Ans=" " : F1 :" " : F2
end
end
These are the test cases for the code.
The code is not giving proper output for
86396 to 86399. Rest all problematic cases are manipulated to near actual result. OCONV function does not work for inputs (-1 to-4) & 86396 to 863999).
please let me know about the same.
Thanks
OConv functionality
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: