Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Function PBMain() As Long
Local tempDirData As DirData, temp$
Local ST,LST As SystemTime, FT,LFT As FileTime
CustomDateToST(Date$,ST)
? FormatST(ST,1)
'time.txt Date/Time is 8-17-2011 7:54pm in my PC (Explorer)
temp$ = Dir$("time.txt", To tempDirData)
FileTimeToSystemTime(ByVal VarPtr(tempDirData.LastWriteTime), ST) 'UTC to UTC
? FormatST(ST,1)
temp$ = Dir$("time.txt", To tempDirData) 'UTC
FileTimeToSystemTime(ByVal VarPtr(tempDirData.LastWriteTime),ST) 'UTC
SystemTimeToTzSpecificLocalTime(ByVal %Null, ST,LST) 'Local
? FormatST(LST,0) '0=12hr format 1=24hr format
End Function
Function FormatST(ByVal ST As SystemTime, Optional ByVal Flag24 As Long) As String '1=24 hr time 0=12 hr time
Local F$
F$ = "00"
If Flag24 Then
'24 hour format
Function = Format$(ST.wMonth,F$) + "-" + Format$(ST.wDay,F$) + "-" + Format$(ST.wYear,F$) + " " _
+ Format$(ST.wHour,F$) + ":" + Format$(ST.wMinute,F$) + ":" + Format$(ST.wSecond,F$)
Else
'12 hour format
Function = Format$(ST.wMonth,F$) + "-" + Format$(ST.wDay,F$) + "-" + Format$(ST.wYear,F$) + " " _
+ Format$(IIf(ST.wHour >=0 And St.wHour <=11, IIf(ST.wHour=0,12,ST.wHour), ST.wHour-12),F$) + ":" _
+ Format$(ST.wMinute,F$) + ":" + Format$(ST.wSecond,F$) _
+ IIf$(ST.wHour >=0 And St.wHour <=11, " am"," pm")
End If
End Function
Sub NowToFT(FT As FileTime)
Local temp$, ST As SystemTime
Reset ST
temp$ = Date$
ST.wMonth = Val(Parse$(temp$,"-",1))
ST.wDay = Val(Parse$(temp$,"-",2))
ST.wYear = Val(Parse$(temp$,"-",3))
temp$ = Time$
ST.wHour = Val(Parse$(temp$,"-",1))
ST.wMinute = Val(Parse$(temp$,"-",2))
ST.wSecond = Val(Parse$(temp$,"-",3))
SystemTimeToFileTime(ST,FT)
End Sub
Sub NowToST(ST As SystemTime)
Local temp$
Reset ST
temp$ = Date$
ST.wMonth = Val(Parse$(temp$,"-",1))
ST.wDay = Val(Parse$(temp$,"-",2))
ST.wYear = Val(Parse$(temp$,"-",3))
temp$ = Time$
ST.wHour = Val(Parse$(temp$,"-",1))
ST.wMinute = Val(Parse$(temp$,"-",2))
ST.wSecond = Val(Parse$(temp$,"-",3))
End Sub
Sub CustomDateToST(sDate$, ST As SystemTime)
Reset ST
ST.wMonth = Val(Parse$(sDate$,"-",1))
ST.wDay = Val(Parse$(sDate$,"-",2))
ST.wYear = Val(Parse$(sDate$,"-",3))
End Sub
'gbs_00699
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm