Padding option(s): @Day, @Month, @Doy

Oct 18, 2009
Ability to add user-specified padding for @Day, @Month, @Doy

I routinely create folders with the name format 01 - Jan 2018 or the date format 01, so when I list in File Manager/Windows Explorer I don't wind up with 1, 10, 11, ..., 19, 2, 20, 21 ...

To use the current options I have to prepend a 0 and then take the last 2 characters. (I don't use _doy or @doy.)

Since this often would be returning a string, it might need different variable names, either that or add an optional second parameter to indicate that the function will return a string rather than an integer.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
I realize this is not what you're asking for, but it might be helpful to others....

You can roll your own using FUNCTION:
function day2=`%@formatn[02.0,%@day[%$]]`
function month2=`%@formatn[02.0,%@month[%$]]`
function doy3=`%@formatn[03.0,%@doy[%$]]`
Or, if you're not using @DAY's format parameter, perhaps the likes of this.
v:\> function pday `%@if["%2" eq "p",%@format[02,%@day[%1]],%@day[%1]]`

v:\> echo %@pday[2018-08-06]

v:\> echo %@pday[2018-08-06,p]

v:\> echo %@pday[2018-08-16,p]
Another example of ways to manipuate time. I wanted %_time to spit out am and pm so here is a custom function that does it. Pretty easy. I think Charles's example will do what you need.

TimeAMPM = %@if[%@Left[2,%_Time] LE 12,%_Time AM,%@Format[2,0%@Eval[%@Left[2,%_Time]-12]]:%@FormatN[02.0,%_Minute]:%@FormatN[02.0,%_Second] PM]