#23689 - 2002-06-21 11:42 PM
Convert Win98 time/date to KiX time/date format
|
tarus
Fresh Scripter
Registered: 2002-06-14
Posts: 12
|
I want to convert the format of the time and date that the Win98 command NET TIME \\SERVER gives to the format of the time and date that @TIME and @DATE give. @TIME returns seconds while NET TIME \\SERVER doesn't, so the seconds can be left off.
Here is the format of NET TIME \\SERVER (notice that if the hour and month are <9 then it doesn't have a "0" in front of it): Time: 4:03P.M. "H:MM" + "A.M.|P.M." or "HH:MM" + "A.M.|P.M." Date: 6-21-2002 I am not sure if the day would be "03" or "3"
Here is the format of @TIME and @DATE: 16:03:28 "HH:MM:SS" 2002/06/21 "YYYY/MM/DD"
I am not exactly sure how to go through with this, so help would be appreciated.
|
Top
|
|
|
|
#23690 - 2002-06-22 12:48 AM
Re: Convert Win98 time/date to KiX time/date format
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
See script:
code:
$old_date_format="6-21-2002" $old_time_format="4:03P.M." GOSUB convert_date_time $old_date_format="6-21-2002" $old_time_format="4:03A.M." GOSUB convert_date_time $old_date_format="11-2-2002" $old_time_format="4:03P.M." GOSUB convert_date_time $old_date_format="11-21-2002" $old_time_format="4:03A.M." GOSUB convert_date_time $old_date_format="1-1-2002" $old_time_format="11:03A.M." GOSUB convert_date_time EXIT :convert_date_time $new_yy=Substr($old_date_format,InstrRev($old_date_format,"-")+1,4) $new_mm=Substr($old_date_format,Instr($old_date_format,"-")+1,InstrRev($old_date_format,"-")-1-Instr($old_date_format,"-")) IF (Len($new_mm) = 1) $new_mm="0"+$new_mm ENDIF $new_dd=Substr($old_date_format,1,Instr($old_date_format,"-")-1) IF (Len($new_dd) = 1) $new_dd="0"+$new_dd ENDIF $new_date_format=$new_yy+"/"+$new_mm+"/"+$new_dd ; IF (Instr($old_time_format,"A.M.") <> 0) $new_hh=Substr($old_time_format,1,Instr($old_time_format,":")-1) IF (Len($new_hh) = 1) $new_hh="0"+$new_hh ENDIF $new_mm=Substr($old_time_format,Instr($old_time_format,":")+1,2) ELSE ; -PM- $new_hh=12+Val(Substr($old_time_format,1,Instr($old_time_format,":")-1)) $new_hh=""+$new_hh $new_mm=Substr($old_time_format,Instr($old_time_format,":")+1,2) ENDIF $new_time_format=$new_hh+":"+$new_mm+":00" ? "old date "+$old_date_format+" -> "+$new_date_format ? "old time "+$old_time_format+" -> "+$new_time_format RETURN
the output looks like
code:
old date 6-21-2002 -> 2002/21/06 old time 4:03P.M. -> 16:03:00 old date 6-21-2002 -> 2002/21/06 old time 4:03A.M. -> 04:03:00 old date 11-2-2002 -> 2002/02/11 old time 4:03P.M. -> 16:03:00 old date 11-21-2002 -> 2002/21/11 old time 4:03A.M. -> 04:03:00 old date 1-1-2002 -> 2002/01/01 old time 11:03A.M. -> 11:03:00
greetings.
|
Top
|
|
|
|
#23691 - 2002-06-22 07:23 PM
Re: Convert Win98 time/date to KiX time/date format
|
tarus
Fresh Scripter
Registered: 2002-06-14
Posts: 12
|
Thanks again, MCA. Exactly what I wanted.
|
Top
|
|
|
|
#23692 - 2002-06-24 07:35 PM
Re: Convert Win98 time/date to KiX time/date format
|
tarus
Fresh Scripter
Registered: 2002-06-14
Posts: 12
|
There was an error in that script, MCA. It had to do with the 12 hour, and I believe I fixed it in this code:
code:
$old_date_format="6-21-2002" $old_time_format="4:03P.M." GOSUB convert_date_time $old_date_format="6-21-2002" $old_time_format="4:03A.M." GOSUB convert_date_time $old_date_format="11-2-2002" $old_time_format="4:03P.M." GOSUB convert_date_time $old_date_format="11-21-2002" $old_time_format="4:03A.M." GOSUB convert_date_time $old_date_format="1-1-2002" $old_time_format="11:03A.M." GOSUB convert_date_time EXIT :convert_date_time $new_yy=Substr($old_date_format,InstrRev($old_date_format,"-")+1,4) $new_mm=Substr($old_date_format,Instr($old_date_format,"-")+1,InstrRev($old_date_format,"-")-1-Instr($old_date_format,"-")) IF (Len($new_mm) = 1) $new_mm="0"+$new_mm ENDIF $new_dd=Substr($old_date_format,1,Instr($old_date_format,"-")-1) IF (Len($new_dd) = 1) $new_dd="0"+$new_dd ENDIF $new_date_format=$new_yy+"/"+$new_mm+"/"+$new_dd ; IF (Instr($old_time_format,"A.M.") <> 0) $new_hh=Substr($old_time_format,1,Instr($old_time_format,":")-1) IF ($new_hh = 12) $new_hh = "00"; ENDIF IF (Len($new_hh) = 1) $new_hh="0"+$new_hh ENDIF $new_mm=Substr($old_time_format,Instr($old_time_format,":")+1,2) ELSE ; -PM- $new_hh=Val(Substr($old_time_format,1,Instr($old_time_format,":")-1)) IF ($new_hh <> 12) $new_hh = $new_hh + 12 ENDIF $new_hh=""+$new_hh $new_mm=Substr($old_time_format,Instr($old_time_format,":")+1,2) ENDIF $new_time_format=$new_hh+":"+$new_mm+":00" ? "old date "+$old_date_format+" -> "+$new_date_format ? "old time "+$old_time_format+" -> "+$new_time_format RETURN
|
Top
|
|
|
|
#23693 - 2002-06-24 09:36 PM
Re: Convert Win98 time/date to KiX time/date format
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Thanks. We doesn't try that value.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|