hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_time_date_string_compare (x05ac)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_time_date_string_compare (x05ac) compares two date/time character strings, each stored in the format returned by nag_time_date_array_string (x05ab).

Syntax

[result] = x05ac(ctime1, ctime2)
[result] = nag_time_date_string_compare(ctime1, ctime2)

Description

nag_time_date_string_compare (x05ac) compares two date/time character strings, and returns an integer that specifies which one is the earliest. The result is an integer returned through the function name, with meaning as follows:

References

None.

Parameters

Compulsory Input Parameters

1:     ctime1 – string
2:     ctime2 – string
The date/time strings to be compared. These are expected be in the format returned by nag_time_date_array_string (x05ab), although nag_time_date_string_compare (x05ac) will still attempt to interpret the strings if they vary slightly from this format. See Further Comments for further details.

Optional Input Parameters

None.

Output Parameters

1:     result int64int32nag_int scalar
The result of the function.

Error Indicators and Warnings

None.

Accuracy

Not applicable.

Further Comments

For flexibility, nag_time_date_string_compare (x05ac) will accept various formats for the two date/time strings ctime1 and ctime2.
The strings do not have to be the same length. It is permissible, for example, to enter with one or both of the strings truncated to a smaller length, in which case missing fields are treated as zero.
Each character string may be of any length, but everything after character 80 is ignored.
Each string may or may not include an alphabetic day name, such as ‘Wednesday’, at its start. These day names are ignored, and no check is made that the day name corresponds correctly to the rest of the date.
The month name may contain any number of characters provided it uniquely identifies the month, however all characters that are supplied are significant.
Fields in the character string must be separated by one or more spaces.
The case of all alphabetic characters is not significant.
Any field in a date time string that is indecipherable according to the above rules will be converted to a zero value internally. Thus two strings that are completely indecipherable will compare equal.
According to these rules, all the following date/time strings are equivalent:

Example

This example initializes two date/time strings, and compares them by a call to nag_time_date_string_compare (x05ac).
function x05ac_example


fprintf('x05ac example results\n\n');

ctime1 = 'Thu 27th April 1989 13:15:21.320                  ';
ctime2 = 'Wed 26th April 1989 11:23:14.130                  ';

[result] = x05ac(ctime1, ctime2);

if result<0
  compare = 'is earlier than';
elseif result==0
  compare = 'is the same as';
else
  compare = 'is later than';
end
fprintf('%s\n%s\n%s\n',ctime1,compare,ctime2);


x05ac example results

Thu 27th April 1989 13:15:21.320                  
is later than
Wed 26th April 1989 11:23:14.130                  

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015