Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
System date
Message
From
08/07/2006 11:51:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/07/2006 11:12:04
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
01134668
Message ID:
01134691
Views:
26
>* change date
>* thisform.dnewdate is the new date
>
>DECLARE INTEGER SetLocalTime IN Kernel32 AS SST STRING @ PTIME
>CLEAR
>
>WITH THISFORM
> n_Year = YEAR(.dNewdate)
> n_Month = MONTH(.dNewdate)
> n_DayOfWeek = DOW(.dNewdate)
> n_Day = DAY(.dNewdate)
> n_Hour = HOUR(.dNewdate)
> n_Minutes = MINUTE(.dNewdate)
> n_Seconds = SEC(.dNewdate)
> n_MSeconds = 0
>ENDWITH
>
>c_Year = CHR( n_Year%256) + CHR( n_Year/256)
>c_Month = CHR( n_Month%256) + CHR( n_Month/256)
>c_DayOfWeek = CHR( n_DayOfWeek%256) + CHR( n_DayOfWeek/256)
>c_Day = CHR( n_Day%256) + CHR( n_Day/256)
>c_Hour = CHR( n_Hour%256) + CHR( n_Hour/256)
>c_Minutes = CHR( n_Minutes%256) + CHR( n_Minutes/256)
>c_Seconds = CHR( n_Seconds%256) + CHR( n_Seconds/256)
>c_MSeconds = CHR( n_MSeconds%256) + CHR( n_MSeconds/256)
>
>yy = c_Year + c_Month + c_DayOfWeek + c_Day + c_Hour + c_Minutes + c_Seconds + c_MSeconds
>SST( @yy)

Note: You need call it twice:)
ltNow = Datetime()
? 'Now',Datetime()
SetSystemDate({^2002/1/3})
? 'Set to',Datetime()
SetSystemDate(m.ltNow)
? 'Set back to',Datetime()


Function SetSystemDate
  Lparameters tdDate
  Declare Integer SetLocalTime In win32api String @ lpTime
  Declare Integer GetLocalTime In win32api String @ lpTime
  Local lpCurrent, lcNewTime
  lpCurrent = Space(40)
  GetLocalTime(@lpCurrent) && save current

  lcNewTime = Num2Word(Year(m.tdDate))+;
    Num2Word(Month(m.tdDate))+;
    Num2Word(Dow(m.tdDate))+;
    Num2Word(Day(m.tdDate))+;
    Substr(m.lpCurrent,9)

  SetLocalTime(@lcNewTime)
  SetLocalTime(@lcNewTime)
EndFunc

Function Num2Word
  Lparameters tnDecimal
  Return Chr(m.tnDecimal%256)+Chr(Int(m.tnDecimal/256))
EndFunc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform