Liberty BASIC Community Forum
« Response to: Addition to TIME$() »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 6:08pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Response to: Addition to TIME$()  (Read 192 times)
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1123
xx Response to: Addition to TIME$()
« Thread started on: Nov 15th, 2016, 9:35pm »

In response to JohnnyD's Addition to TIME$() thread in the Liberty BASIC Wishlist board requesting some updates to the Time$() function I figured I would post a couple of functions that might be of use to some people; with a coupe extra ones for good measure.

Code:
'____________________________________________________________________________________________________________________________________
'____________________________________________________________________________________________________________________________________

    Function stringTimeToMS(sTime$)
        stringTimeToMS = (Val(Word$(sTime$, 1, ":")) * 3600000) + _
                         (Val(Word$(sTime$, 2, ":")) * 60000) + _
                         (Val(Word$(sTime$, 3, ":")) * 1000)
    End Function

'____________________________________________________________________________________________________________________________________
'____________________________________________________________________________________________________________________________________

    Function Year()
        Year = Val(Word$(Date$("yyyy/mm/dd") , 1, "/"))
    End Function

'____________________________________________________________________________________________________________________________________
'____________________________________________________________________________________________________________________________________

    Function Month()
        Month = Val(Word$(Date$("yyyy/mm/dd") , 2, "/"))
    End Function

'____________________________________________________________________________________________________________________________________
'____________________________________________________________________________________________________________________________________

    Function Day()
        Day = Val(Word$(Date$("yyyy/mm/dd") , 3, "/"))
    End Function

'____________________________________________________________________________________________________________________________________
'____________________________________________________________________________________________________________________________________

    Function msToStringTime$(msTime)
        If msTime > stringTimeToMS("24:00:00") Then msTime = (msTime MOD stringTimeToMS("24:00:00"))
        If msTime < 0 Then
            If Abs(msTime) > stringTimeToMS("24:00:00") Then
                msTime = (stringTimeToMS("24:00:00") - (Abs(msTime) MOD stringTimeToMS("24:00:00")))
            Else
                msTime = (stringTimeToMS("24:00:00") + msTime)
            End If
        End If
        'Print Int(msTime/ 3600000)
        hr$ = "00" + str$(Int(msTime/ 3600000))
        min$ = "00" + str$(Int((msTime - (Val(hr$) * 3600000))/ 60000))
        sec$ = "00" + str$(Int((msTime - ((Val(hr$) * 3600000) + (Val(min$) * 60000)))/ 1000))
        msToStringTime$ = Right$(hr$,  2) + ":" + Right$(min$, 2) + ":" + Right$(sec$, 2)
    End Function 



I hope someone gets some use out of them.


{:0)

Brandon



User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls