GFTime/GFTimemod.bas
Attribute VB_Name = "GFTimemod"
Option Explicit
'(c)1999, 2002 by Louis.
'GFTime_GetFormatted[Time/Date]$
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
'GFTime_GetFormatted[Time/Date]$
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Public Function GFTime_GetFormattedTime$()
'On Error Resume Next 'returns the current system time in format hh:mm:ss
Dim SYSTEMTIMEVar As SYSTEMTIME
Dim TimeHour As String
Dim TimeMinute As String
Dim TimeSecond As String
Dim TimeTempstr$
'preset
Call GetSystemTime(SYSTEMTIMEVar)
TimeHour = LTrim$(Str$(SYSTEMTIMEVar.wHour))
TimeMinute = LTrim$(Str$(SYSTEMTIMEVar.wMinute))
TimeSecond = LTrim$(Str$(SYSTEMTIMEVar.wSecond))
'verify
If Len(TimeHour) = 1 Then TimeHour = "0" + TimeHour
If Len(TimeMinute) = 1 Then TimeMinute = "0" + TimeMinute
If Len(TimeSecond) = 1 Then TimeSecond = "0" + TimeSecond
'begin
TimeTempstr$ = TimeHour + ":" + TimeMinute + ":" + TimeSecond
If Len(TimeTempstr$) = 8 Then 'verify
GFTime_GetFormattedTime$ = TimeTempstr$ 'ok
Else
GFTime_GetFormattedTime$ = "00:00:00" 'error
End If
End Function
Public Function GFTime_GetFormattedDate$()
'On Error Resume Next 'returns the current system date in the format dd‑mm‑yyyy
Dim SYSTEMTIMEVar As SYSTEMTIME
Dim DateDay As String
Dim DateMonth As String
Dim DateYear As String
Dim DateTempstr$
'preset
Call GetSystemTime(SYSTEMTIMEVar)
DateDay = LTrim$(Str$(SYSTEMTIMEVar.wDay))
DateMonth = LTrim$(Str$(SYSTEMTIMEVar.wMonth))
DateYear = LTrim$(Str$(SYSTEMTIMEVar.wYear))
'verify
If Len(DateDay) = 1 Then DateDay = "0" + DateDay
If Len(DateMonth) = 1 Then DateMonth = "0" + DateMonth
'begin
DateTempstr$ = DateDay + "‑" + DateMonth + "‑" + DateYear
If Len(DateTempstr$) = 10 Then
GFTime_GetFormattedDate$ = DateTempstr$ 'ok
Else
GFTime_GetFormattedDate$ = "01‑01‑0001" 'error
End If
End Function
[END OF FILE]