Jump to content

_DateTimeSplit strips leading 0


Cyri
 Share

Recommended Posts

  • Developers

Why does _DateTimeSplit() strip off the leading 0 on the month and day? Almost all the other date functions use dd and mm. Why not the split?

This is because this UDF is designed to calculate with the date and time values.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This is because this UDF is designed to calculate with the date and time values.

Jos

I just wasn't expecting it is all. If I pass in 05 for the month I would expect the result to be 05 and not 5. I just looked at the function in Date.au3 and I see now why it doesn't. By the way, what's the easiest way to pad with a 0 in that case? Check the length?

_DateTimeSplit("2007/05/07", $aDate, $aTime)
If StringLen($aDate[2]) < 2 Then
    $aDate[2] = "0" & $aDate[2]
EndIf
If StringLen($aDate[3]) < 2 Then
    $aDate[3] = "0" & $aDate[3]
EndIf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...