Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

C() Format Code


The C() format code is used to transfer calendar (Julian date and/or time) data.

The syntax is:

[n]C([c0,c1,...,cx]) 

where the parameter "n" is as described in Syntax of Format Codes and:

ci
represents optional calendar format subcodes, or any of the standard format codes that are allowed within a calendar specification, as described below

If no ci are provided, the data will be transferred using the standard 24-character system format that includes the day, date, time, and year, as shown in this string:

Thu Aug 13 12:01:32 1979  

For input, this default is equivalent to:

C(CDwA, X, CMoA, X, CDI, X, CHI, X, CMI, X, CSI, CYI5) 

For output, this default is equivalent to:

C(CDwA, X, CMoA, X, CDI2.2, X, CHI2.2, ":", CMI2.2, ":", CSI2.2, CYI5) 
 

Note
The C() format code represents an atomic data transfer. Nesting within the parentheses is not allowed.

Note
For input using the calendar format codes, a small offset is added to each Julian date to eliminate roundoff errors when calculating the day fraction from hours, minutes, and seconds. This offset is given by the larger of EPS and EPS*Julian, where Julian is the integer portion of the Julian date, and EPS is the EPS field from MACHAR. For typical Julian dates, this offset is approximately 6x10-10 (which corresponds to 5x10-5 seconds). This offset ensures that if the Julian date is converted back to hour, minute, and second, then the hour, minute, and second will have the same integer values as were originally input.

Note
Calendar dates must be in the range 1 Jan 4716 B.C.E. to 31 Dec 5000000, which corresponds to Julian values -1095 and 1827933925, respectively.

Calendar Format Subcodes

The following is a list of the subcodes allowed within the parenthesis of the C() format code.

Note
The calendar format subcodes are based on the A, I, and F format codes, and share the same options. See Syntax of Format Codes for additional information on the parameters not described explicitly in this section. Note that the default values of the w and d parameters are different in the calendar format subcodes than in the base A, I, and F format codes.

CMOA subcodes

The CMOA subcodes transfers the month portion of a date as a string. The format for an all upper case month string is:

CMOA[-][w]  

The format for a capitalized month string is:

CMoA[-][w] 

The format for an all lower case month string is:

CmoA[-][w] 

where:

w
is an optional width (0 £ £ 256) specifying the number of characters of the month name to be transferred. If w is not specified, three characters will be transferred. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.

Note
The case of the `M' and `O' of these subcodes will be ignored on input, or if the MONTHS keyword for the current routine is explicitly set.

CMOI subcode

The CMOI subcode transfers the month portion of a date as an integer. The format is as follows:

CMOI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 2. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CDI subcode

The CDI subcode transfers the day portion of a date as an integer. The format is:

CDI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 2. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CYI subcode

The CYI subcode transfers the year portion of a date as an integer. The format is as follows:

CYI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 4. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CHI subcodes

The CHI subcodes transfer the hour portion of a date as an integer. The format for a 24-hour based integer is:

CHI[+][-][w][.m] 

The format for a 12 hour based integer is:

ChI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 2. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CMI subcode

The CMI subcode transfers the minute portion of a date as an integer. The format is:

CMI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 2. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CSI subcode

The CSI subcode transfers the seconds portion of a date as an integer. The format is:

CSI[+][-][w][.m] 

where:

w
is an optional width (0 £ £ 256) specifying the width of the field in characters. The default width is 2. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
m
is an optional minimum number (1 £ £ 256) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.
Note - The m parameter is ignored if w is zero.

CSF subcode

The CSF subcode transfers the seconds portion of a date as a floating-point value. The format is:

CSF[+][-][w][.d] 

where:

w
is an optional width specification (0 £ £ 256). The variable w specifies the number of characters in the external field; the default is 5. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.
d
is an optional width specification (1 £ d < w). The variable d specifies the number of positions after the decimal point; the default is 2.

Overflow

The value of w must be large enough to include at least one digit to the left of the decimal point, the decimal point, and d digits to the right of the decimal point. On output, if the field provided is not wide enough, it is filled with asterisks (*) to indicate the overflow condition.

CDWA subcodes

The CDWA subcodes transfers the day of week portion of a data as a string. The format for an all upper case day of week string is:

CDWA[-][w]  

The format for a capitalized day of week string is:

CDwA[-][w] 

The format for an all lower case day of week string is:

CdwA[-][w] 

where:

w
is an optional width (0 £ £ 256), specifying the number of characters of the day of week name to be transferred. If w is not specified, three characters will be transferred. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.

Note
The case of the `D' and `W' of these subcodes will be ignored on input, or if the DAYS_OF_WEEK keyword for the current routine is explicitly set.

CAPA subcodes

The CAPA subcodes transfers the am or pm portion of a date as a string. The format for an all upper case AM or PM string is:

CAPA[-][w]  

The format for a capitalized AM or PM string is:

CApA[-][w] 

The format for an all lower case AM or PM string is:

CapA[-][w] 

where:

w
is an optional width (0 £ £ 256), specifying the number of characters of the AM or PM string to be transferred. If w is not specified, two characters will be transferred. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.

Note
The case of the first `A' and `P' of these subcodes will be ignored on input, or if the AM_PM keyword for the current routine is explicitly set.

Standard Format Codes Allowed within a Calendar Specification

None of these subcodes are allowed outside of a C() format specifier. In addition to the subcodes listed above, only quoted strings, "TL", "TR", and "X" format codes are allowed inside of the C() format specifier.

Example:

To print the current date in the default format:

PRINT, FORMAT='(C())', SYSTIME(/JULIAN) 

The printed result should look something like:

Fri Aug 14 12:34:14 1998 
Example:

To print the current date as a two-digit month value followed by a slash followed by a two-digit day value:

PRINT, FORMAT='(C(CMOI,"/",CDI))',SYSTIME(/JULIAN) 

The printed result should look something like:

8/14 
Example:

To print the current time in hours, minutes, and floating-point seconds, all zero-filled if necessary, and separated by colons:

PRINT, $ 
   FORMAT='(C(CHI2.2,":",CMI2.2,":",CSF05.2))',SYSTIME(/JULIAN) 

The printed result should look something like:

09:59:07.00 

Note that to do zero-filling for the floating-point seconds, it is necessary to specify a leading 0 in the width to the CSF format code.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]