Opened 10 years ago

Closed 3 years ago

#24 closed enhancement (fixed)

Add ability to format internal variables

Reported by: Lewis Rosenthal Owned by: Gregg Young
Priority: minor Milestone: Version-3.10
Component: Base Version: 3.08
Keywords: Cc:

Description

Presently, _DATE (in the US locale) results in:

mm-dd-yy

which makes it unsuitable for such things as using it in batch scripts for creating date-based directory names, when one wants to sort them by yyyy-mm-dd.

Similarly, _DAY results in:

dd

or

d

(the latter when the current date is prior to the 10th of the month). This means that when padding is desired, it must be explicitly stated, as in:

%@right[2,0%_DAY%]

which can be cumbersome for the part-time scripter, such as I.

I propose adding the ability to format such strings either with INI settings or ENV vars, e.g.:

SET DATEFMT=YYYY-MM-DD

or

SET DAYFMT=DD

Use case:

What I wanted was a simple one-liner for a command line to create a target directory for rsync, as in:

X:\{hostname}\%_DATE\{volume}

so that the above would be expanded to something like:

X:\laptop\2013-12-08\DATA

To achieve that formatting with 4OS2 3.08, the code would be:

X:\{hostname}\%[_YEAR]-%@right[2,0%_MONTH]-%@right[2,0%_DAY]\{volume}

which seems a bit cumbersome.

Change History (3)

comment:1 Changed 5 years ago by Steven Levine

Milestone: Version-3.09Version-3.10

Ticket retargeted after milestone closed

comment:2 Changed 3 years ago by Gregg Young

Owner: set to Gregg Young
Status: newaccepted

comment:3 Changed 3 years ago by Gregg Young

Resolution: fixed
Status: acceptedclosed

Rev 38327 & 38301

Note: See TracTickets for help on using tickets.