Glindra
Documentation Index Download
Command Line File Handling and ASCII Tools

Date and Time

Parsing Dates and Times

When you give only a time and no date, the date defaults to the current date.

Example

> d '*.*' -since=12:00
will list all files that have been created since noon today.


If you want to specify both a date and a time, you must enclose the specification in parentheses.

Example (Windows)
> d *.* -since=(1-jun-2004 18:00)
Example (Linux)
> d '*.*' -since=\(1-jun-2004 18:00\)

Parsing Dates

When a date is read, it should be given on the default dd-MMM-yyyy format.
Examples
> d -before=2-mar-2000
> d -since=31-oct

If you leave out the year, the current year is used as default.

Dates cannot be given on comparison format.

Today, yesterday, tomorrow

When dates are read, the three special date names today, yesterday, and tomorrow are also accepted. The keywords can be abbreviated as long as the are unique.

When you only specify a date without any time, this is interpreted to mean 00:00h on that date. This means that the command

> d -since=today
will list all files that have been created since 00:00h on the current date, which of course is what you would expect.

Similarly, the command

> d -before=today
will list all files that have been created before 00:00h on the current date, but not the files that were created today.

Parsing Times

Times can be specified on the following formats
hh:mm
hh:mm:ss
hh:mm:ss.fff

where
hh Hour between 0 and 23, with one or two digits
mm Minutes between 0 and 59, always with two digits.
ss Seconds between 0 and 59, always with two digits (if the field is present at all).
fff Fractions of a second, with as many digits as you find meaningful

Examples
0:23
00:23
19:27:56
19:27:56.028

Printing Dates and Times

Printing dates

The default format for printing dates is

 2-Mar-2000
Day as a two character number where the first one can be blank, three letter abbreviation of the month in English, with proper capitalization, and the year with four digits.

This format has the advantage that it is unambiguously understandable to most people. More people are certain about the names of the months in English than about the order that different cultures put numbers in. US-centric numeric formats are really inconvenient to Europeans.


The default format is not sortable by a standard sort utility, however. To get a format that is, we can specify sortable.

Example
> d -date=sortable

Directory of e:\work\test\data\

       <DIR>    2004-01-20 12:29:22   boost
       <DIR>    2004-01-20 12:29:09   junk
       <DIR>    2004-01-20 12:29:07   SONG
          22    2003-12-03 20:54:15   .hejsan
         115    2002-05-28 11:37:10   00readme.txt.~1~
         170    2004-03-18 17:44:34   00readme.txt
          15    2002-06-13 18:18:56   bar
          29    2002-06-13 18:18:38   foo
          19    2002-06-13 18:19:30   foo bar
  ----------
         370   total, 9 files


Other formats can be specified as well, like for example:

March 2, -00
03/02/00
MAR02
See Date/Time Syntax below for more on how to do this.

Printing times

The default format for printing times is

15:35:00
Other formats can be specified as well. See Date/Time Syntax below for more on this.

The twelve hour format with am/pm is not yet implemented.

Date/Time Syntax

Example (Windows)
> d -date=(date_only width=12)
Example (Linux)
> d -date=\(date_only width=12\)
Suboptions
default 2-Mar-2000 09:30:00
sortable 2000-03-02 09:30:00
date_only 2-Mar-2000
time_only 09:30:00
format = format_string Give an explicit datetime format string.
exact 2-Mar-2000 - Month in exact case. This is the default.
noexact Same meaning as lower.
lower 2-mar-2000 - Month in lower case.
upper 2-MAR-2000 - Month in upper case.
title 2-Mar-2000 - Month in title case.
width = n Minimum width in characters. 0 means left adjusted.
hide Hide the item.
Example (Windows)
> d -date=(format=MMMdd upper wid=0)

Directory of e:\work\test\data\

       <DIR>   JAN20   boost
       <DIR>   JAN20   junk
       <DIR>   JAN20   SONG
          22   DEC03   .hejsan
         115   MAY28   00readme.txt.~1~
         170   MAR18   00readme.txt
          15   JUN13   bar
          29   JUN13   foo
          19   JUN13   foo bar
  ----------
         370   total, 9 files


Datetime Format

With the format suboption you can provide a format string to determine in detail how dates and times should be written.

Example (Windows)
> d /date=(format="MMMM d, yyyy at H:mm" wid=25)

Directory of e:\work\test\data\

       <DIR>   January 20, 2004 at 12:29   boost
       <DIR>   January 20, 2004 at 12:29   junk
       <DIR>   January 20, 2004 at 12:29   SONG
          22   December 3, 2003 at 20:54   .hejsan
         115       May 28, 2002 at 11:37   00readme.txt.~1~
         170     March 18, 2004 at 17:44   00readme.txt
          15      June 13, 2002 at 18:18   bar
          29      June 13, 2002 at 18:18   foo
          19      June 13, 2002 at 18:19   foo bar
  ----------
         370   total, 9 files


Datetime format specifiers

Specifier Example Description
yyyy 2000 Year with four digits.
yy 00 Year with two digits.
M 3 Month with one or two digits.
xM 3 Month with one or two digits, and with a leading blank in front of it, if it is only one digit.
MM 03 Month with two digits. Months between 1 and 9 are written with a leading zero.
MMM Mar Month with three letters.
MMMM March Full name of the month.
d 2 Day of the month with one or two digits.
xd 2 Day of the month with one or two digits, and with a leading blank in front of it, if it is only one digit.
dd 02 Day of the month with two digits. Days between 1 and 9 are written with a leading zero.
H 9 Hour (0-23) with one or two digits.
xH 9 Hour (0-23) with one or two digits, and with a leading blank in front of it, if it is only one digit.
HH 09 Hour (0-23) with two digits. Hours between 1 and 9 are written with a leading zero.
mm 30 Minute.
ss 00 Second.
{ }
Curly brackets are used for separating the date and time portions of the format from each other.

If a segment within curly brackets contains only date related specifiers, that segment will be used for writing out dates that have no associated time.

If a segment within curly brackets contains only time related specifiers, it will be used for writing times that have not associated date.


Printing times with the 12 hour clock and an am/pm indicator is not yet implemented.

Datetime Format String Examples

Examples of datetime format strings. The first four formats are available as predefined options to datetime syntax.
Option Format string Output
default "{xd-MMM-yyyy} {HH:mm:ss}" 2-Mar-2000 09:30:00
sortable "{yyyy-MM-dd} {HH:mm:ss}" 2000-03-02 09:30:00
date_only "xd-MMM-yyyy" 2-Mar-2000
time_only "HH:mm:ss" 09:30:00

"MMMM d, yyyy" March 2, 2000

"MMMM d, yyyy at H:mm" March 2, 2000 at 9:30

"xd-MMM-yyyy HH:mm:ss" 2-Mar-2000 09:30:00

"yyyy-MM-dd HH.mm" 2000-03-02 09.30

"yyyyMMdd" 20000302

"H:mm" 9:30