Page 1 of 1 1
Topic Options
#23689 - 2002-06-21 11:42 PM Convert Win98 time/date to KiX time/date format
tarus Offline
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 Offline
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.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#23691 - 2002-06-22 07:23 PM Re: Convert Win98 time/date to KiX time/date format
tarus Offline
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 Offline
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 Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Thanks. We doesn't try that value.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.055 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org