$Date - Macros

Far Manager

$Date

The $Date macro-command inserts the current date/time into the current object editor.
$Date ["format"]

Arguments

format
The current date/time is converted to a string according to the "format" parameter. Its meaning is similar to the Unix 'date' function formatting parameter. $Date supports the following format specification (similar to the format used by the strftime function):
Format Description
%% Percent sign (%)
%a Abbreviated day of week name (Sun)
%A Full day of week name (Sunday)
%b Abbreviated month name (Jan)
%B Full month name (January)
%c Date and time representation in the format: WDay Mnt Day HH:MM:SS yyyy (Mon Jan 10 04:11:54 2000)
%C Century as a decimal number (00 - 99). 1992 => 19
%d Day of the month as decimal number (01 - 31)
%D Same as %x
%e Similar to %d, but the leading zero is replaced with a space.
%h Same as %b
%H Hour in 24-hour format (00 - 23)
%I Hour in 12-hour format (01 - 12)
%j Day of year as decimal number (001 - 366)
%k Similar to %H, but the leading zero is replaced with a space.
%l Similar to %I, but the leading zero is replaced with a space
%L Use the localized set of names of months and days rather then English.
FAR Manager requests two sets of names from the system during startup:
1) English names of months and weekdays
2) names according to the current user's localization settings (LOCALE_USER_DEFAULT).
By default the English names are used.
%m Month as decimal number (1 - 12)
%m0 Similar to %m, but with a leading zero (01 - 12)
%mh Current month as hexadecimal number (1 - C)
%M Minute as decimal number (00 - 59)
%n Line break `\\n'
ATTENTION! Using this specifier in the editor macros will switch the auto indentation off.
%p AM or PM
%r Same as %I:%M:%S %p
%R Same as %H:%M
%S Seconds as decimal number (00 - 59)
%t Tab character `\\t'
%T Same as %X
%U Week of year as decimal number, with Sunday as first day of week (00 - 53)
%v Date in the format dd-mmm-yyyy (mmm - the month name is in upper case)
%V Week of year according to ISO 8601:
"If the week number containing January 1st has >= 4 days in the new year, then it is week 1; otherwise, it is the last numbered week of the previous year (52 or 53)"
%w Day of week as decimal number (0 - 6, Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 - 53)
%x Date in the format dd<sep>mm<sep>yyyy (the separator <sep> and the order of day, month and year are determined from the regional settings)
%X Time in the format HH<sep>MM<sep>SS the separator <sep> is determined from the regional settings)
%y Year without century, as decimal number (00 - 99)
%Y Year with century, as decimal number (19yy-20yy)
%Z Time-zone name or abbreviation, nothing if time zone is unknown

Format string must be encoded using the OEM codepage.
The following escape sequences are allowed:

Format Description
\" The '"' character
\' The ''' character
\\ The '\' character
\n New line `\n'
\t Tab `\t'
\a bell
\b `\b'
\f `\f'
\v `\v'
\N
\NN
\NNN
Octal characters code for the OEM code page
\xNN Hexadecimal characters code for the OEM code page

Notes

  1. It is impossible to use macro-language elements while recording a macro in a usual way. Macro-language elements can be added to the sequence only by editing the registry manually or by using special applications or FAR plugins.
  2. If the "format" argument is not specified FAR uses the "%a %b %d %H:%M:%S %Z %Y" format string.

Example

REGEDIT

;insertion of current date

[HKEY_CURRENT_USER\Software\Far\KeyMacros\Common\CtrlD]
"Sequence"="$If (Editor || Dialog || Search) $Date \"%d.%m0.%Y\" Space $Else CtrlD $End"
"DisableOutput"=dword:00000001
See also: