# $timestamp(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

$timestamp - Time stamp string

## SYNOPSIS

$timestamp "string"; Default is "`<%Y%M%D.%h%m>`"

## DESCRIPTION

$timestamp defines the file time-stamping string. MicroEmacs 2009 searches for, and modifies, the string to the current time and date whenever the file is saved (written to disk) and time(2m) mode is enabled.

Time stamp string is defined, by default, as "`<%Y%M%D.%h%m>`". The first occurrence of the string in the file is up-dated with the time and date information when the buffer is written. The $timestamp string may contain any text, and includes the following, magic characters escaped by a percentage (``%`') character:-

`D` - Day.
`M` - Month.
`Y` - Year.
`h` - Hour.
`m` - Minute.
`s` - Second.

The format string may be redefined into any format. The '`%`' character has to be delimited by another '`%`' if it is to be used in the text (i.e. "`%%`").

The year component (`%Y`) may be a 2 or 4 digit string, depending whether it includes the century. When the time stamping searches for the `%Y` component it searches for either variant and replaces appropriately.

## EXAMPLE

The startup file may define the time stamp required as follows:-

    set-variable $timestamp "Last Modified : %Y/%M/%D %h:%m:%s"

Time stamping is performed on the string :-

    Last Modified : 90/11/23 10:12:01

Where the time stamp is modified according to the file (buffer) type then the time stamp string may be modified within the buffer hooks. This allows different files to utilize different time stamping strings. The following example shows how the entry and exit buffer hooks are defined to modify the string:

    0 define-macro bhook-nroff
        set-variable .timestamp $timestamp
        ; Buffer specific time stamp string.
        set-variable $timestamp "[%Y/%M/%D %h:%m:%s]"
    !emacro
    0 define-macro ehook-nroff
        ; Restore the existing time stamp.
        set-variable $timestamp .bhook-nroff.timestamp
    !emacro

On entry to the buffer (buffer becomes current) the buffer hook bhook-nroff is executed which stores the current setting and then modifies the time stamp string. On exit from the buffer the buffer hook ehook-nroff is executed restoring the time stamp string.

## SEE ALSO

buffer-mode(2) time(2m).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>