Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-19-2003, 04:41 PM
ShaneJimmerson ShaneJimmerson is online now
Registered User
 
Join Date: 12-12-2003
Posts: 19
Formatting Date and Time

Is there an easy way to format the current date and time in the following format:

dd/mm/yyyy;hh:mm[a|p]

Here is a sample:
12/19/2003;04:34p

I would like to set a macro with the date and time of the current build in the format above so that I can run a SourceSafe history report of all changes since the last build.

I would appreciate any suggestions that you might have.

Thanks,
Shane
Reply With Quote
  #2  
Old 12-19-2003, 06:20 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
I think VSS actually wants the date in mm/dd/yy format. Anyway, you can tweak this code as necessary (paste into your global or project scripts in the Script Editor):

Function FormatDateVSS()
' returns the current date+time in the form
' mm/dd/yy;hh:mm[a|p]

Dim dte, h, p

dte = Now
h = Hour(dte)
If h >= 12 Then
p = "p"
h = h - 12
Else
p = "a"
If h = 0 Then h = 12
End If
FormatDateVSS = vbld_PadLeft(CStr(Month(dte)), 2, "0") & "/" & _
vbld_PadLeft(CStr(Day(dte)), 2, "0") & "/" & _
vbld_PadLeft(CStr(Year(dte)), 2, "0") & ";" & _
vbld_PadLeft(CStr(h), 2, "0") & ":" & _
vbld_PadLeft(CStr(Minute(dte)), 2, "0") & p

End Function


And use in a step field like

[FormatDateVSS]


For instance,

<step action='Log Message' type='0'>
<Message>formatted date = [FormatDateVSS]</Message>
<indent type='3'>1</indent>
<name>New Step</name>
</step>
Reply With Quote
  #3  
Old 01-05-2004, 12:24 PM
GrahamS GrahamS is online now
Registered User
 
Join Date: 12-26-2003
Posts: 16
Actually VSS uses the locale to determine the date format. European users of VSS will (mostly) have dates in dd/mm/yy format, whilst North American users (and others) will have the mm/dd/yy format
Reply With Quote
  #4  
Old 01-05-2004, 01:04 PM
ShaneJimmerson ShaneJimmerson is online now
Registered User
 
Join Date: 12-12-2003
Posts: 19
Thanks for the info.

The VBScript you posted worked fine, but I was also trying to do it with JScript and it returns <object> instead of the formatted date and time. I also tried some other JScript functions like vbld_FormatDateTime and they alse returned <object>. Is this a limitaion of using JScript or is there something else that I need to do?
Reply With Quote
  #5  
Old 01-05-2004, 01:16 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
You should be able to use .toString() on any JScript expression to force it to be evaluated as a string.
Reply With Quote
  #6  
Old 01-05-2004, 01:43 PM
ShaneJimmerson ShaneJimmerson is online now
Registered User
 
Join Date: 12-12-2003
Posts: 19
I did not realize that you had to use parenthasis when calling a JScript function from a step field.

I was just using

[FormatDateVSSJScript]

when I should have been using

[FormatDateVSSJScript()]

Thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 03:24 AM.


Copyright © 1999-2023 Kinook Software, Inc.