The IccClock class controls access to the CICS® time and date services. IccAbsTime holds information about absolute time (the time in milliseconds that have elapsed since the beginning of 1900), and this can be converted to other forms of date and time. The methods available on IccClock objects and on IccAbsTime objects are very similar.
This sample program demonstrates how to use IccClock class. The source for this program can be found in the samples directory (see Sample source code) as file ICC$CLK. The sample is presented here without the terminal IO requests.
#include "icceh.hpp"
#include "iccmain.hpp"
void IccUserControl::run()
{
The first two lines include the header files for the Foundation Classes and the standard main function that sets up the operating environment for the application program.
The run method of IccUserControl class contains the user code for this example.
IccClock clock;
This creates a clock object.
term->sendLine( "date() = [%s]",
clock.date() );
term->sendLine( "date(DDMMYY) = [%s]",
clock.date(IccClock::DDMMYY) );
term->sendLine( "date(DDMMYY,':') = [%s]",
clock.date(IccClock::DDMMYY,':'));
term->sendLine( "date(MMDDYY) = [%s]",
clock.date(IccClock::MMDDYY));
term->sendLine( "date(YYDDD) = [%s]",
clock.date(IccClock::YYDDD));
Here the date method is used to return the date in the format specified by the format enumeration. In order the formats are system, DDMMYY, DD:MM:YY, MMDDYY and YYDDD. The character used to separate the fields is specified by the dateSeparator character (that defaults to nothing if not specified).
term->sendLine( "daysSince1900() = %ld",
clock.daysSince1900());
term->sendLine( "dayOfWeek() = %d",
clock.dayOfWeek());
if ( clock.dayOfWeek() == IccClock::Friday )
term->sendLine( 40, "Today IS Friday" );
else
term->sendLine( 40, "Today is NOT Friday" );
This fragment demonstrates the use of the daysSince1900 and dayOfWeek methods. dayOfWeek returns an enumeration that indicates the day of the week. If it is Friday, a message is sent to the screen, 'Today IS Friday'; otherwise the message 'Today is NOT Friday' is sent.
term->sendLine( "dayOfMonth() = %d",
clock.dayOfMonth());
term->sendLine( "monthOfYear() = %d",
clock.monthOfYear());
This demonstrates the dayOfMonth and monthOfYear methods of IccClock class.
term->sendLine( "time() = [%s]",
clock.time() );
term->sendLine( "time('-') = [%s]",
clock.time('-') );
term->sendLine( "year() = [%ld]",
clock.year());
The current time is sent to the terminal, first without a separator (that is HHMMSS format), then with '-' separating the digits (that is, HH-MM-SS format). The year is sent, for example 1996.
return;
};
The end of run, which returns control to CICS.
See Appendix C. Output from sample programs for the expected output from this sample program.
[[ Contents Previous Page | Next Page Index ]]