GDL Datetime Add-On

The DateTime extension allows you to set various formats for the current date and time set on your computer.

The Add-On works the same way the GDL file operations. You have to open a channel, read the information and close the channel.

This Add-On is also available by using the REQUEST GDL command, in which case the sequence of commands OPEN, INPUT and CLOSE is called internally.
This is the simplest way to obtain the date/time information, with just a single GDL command line:

REQUEST ("DateTime", format_string, datetimestring)

The second parameter of the Request function is the same as that described in the OPEN function paramstring parameter.

Opening Channel

channel = OPEN (filter, filename, paramstring)

Its return value is a positive integer that will identify the opened channel. This value will become the channel’s future reference number.
The paramstring can contain specifiers and other characters.

filter: the internal name of the Add-On, in this case “DateTime”

filename: unused (there is no need to open any file to get the system date and time)

paramstring: add-on specific parameter, contains the desired output format of the date and time

The specifiers are replaced with date and time values as follows:

%y year without century, as a decimal number (00-99)
%Y year with century, as a decimal number
%b abbreviated month name
%B full month name
%m month, as a decimal number (01-12)
%d day of the month as a decimal number (01-31)
%H hour (24-hour clock), as a decimal number (00-23)
%I hour (12-hour clock), as a decimal number (01-12)
%M minute, as a decimal number (00-59)
%S second, as a decimal number (00-59)
%P AM/PM designation for a 12-hour clock
%c date and time in the form: 01:35:56 PM Wednesday, March 27, 1996
%x date in the form Wednesday, March 27, 1996
%X time in the form 01:35:56 PM
%a abbreviated weekday name
%A full weekday name
%w weekday, as a decimal number (0 (Sunday)-6 (Saturday))
%j day of the year, as a decimal number (001-366)
%U week number of the year (with Sunday as the first day of the first week), as a decimal number
%W week number of the year (with Monday as the first day of the first week), as a decimal number (00-53)
%Z prints the time zone if it can be determined
%% the % character


dstr = ""
ch = OPEN ("DateTime", "", "%w/%m/%d/%Y, %H:%M%P")
n = INPUT (ch, "", "", dstr)
CLOSE (ch)
PRINT dstr !it prints 3/03/27/1996, 14:36 PM

Reading Information

n = INPUT (channel, "", "", datetimestr)

It reads a string type value which represents the date and/or time in the format given at the OPEN sequence.
The second and third parameters are unused (they can be empty strings or 0-s as well)

The return value is the number of successfully read values, in this case 1.

channel: channel value, used to identify the connection.

datetimestr: string type value

Closing Channel

CLOSE channel

Closes the channel identified by the channel value.