 |
» |
|
 |
|
 |

Copyright (c) Digital Equipment Corporation 1989. All rights reserved
LAYERED PRODUCT: PL1 V3.3 OP/SYS: VMS V5.1
SOURCE: Digital Customer Support Center
OVERVIEW:
This program demonstrates using LIB$FORMAT_DATE to select a particular
date format.
*** CAUTION ***
This sample program has been tested using PLI V3.2 on VMS 5.1. However,
we cannot guarantee it's effectiveness because of the possibility of error
in transmitting or implementing it. It is meant to be used as a template
for writing your own program, and it may require modification for use on your
system.
PROGRAM NOTES:
This example calls lib$date_time to return the current date/time, then
sys$bintim to convert it to binary, then lib$day_of_week to translate
to the day of the week, then lib$init_date_time_context to initialize the
new format, and finally lib$format_date_time to create the new date/time.
PROGRAM EXAMPLE:
calc: proc options(main);
%include sys$bintim;
%include lib$date_time;
%include lib$day_of_week;
%include $stsdef;
%include $libdtdef;
%include lib$init_date_time_context;
%include lib$format_date_time;
dcl context fixed bin(31);
dcl date_string char(33);
dcl component fixed bin(31) init(lib$k_output_format);
dcl init_string char(28) init('|!MN0/!D0/!Y2 !H02:!M0 !MIU|');
dcl binary_date bit(64) aligned;
dcl char_date char(23);
dcl day_number fixed bin(31);
dcl day_table(7) char(9);
day_table(1) = 'Monday';
day_table(2) = 'Tuesday';
day_table(3) = 'Wednesday';
day_table(4) = 'Thursday';
day_table(5) = 'Friday';
day_table(6) = 'Saturday';
day_table(7) = 'Sunday';
/* get today's date and time */
sts$value = lib$date_time(char_date);
if ^sts$success
then signal vaxcondition(sts$value);
put skip list ('Today''s date and time is : ', char_date);
/* convert that to the system format */
sts$value = sys$bintim(char_date,binary_date);
if ^sts$success
then signal vaxcondition(sts$value);
/* get the day of the week*/
sts$value = lib$day_of_week(binary_date,day_number);
if ^sts$success
then signal vaxcondition(sts$value);
put skip edit('Today is ',day_table(day_number)) (a,a);
/* initialize the time and date format
in this case init_string was set to the formats corresponding
to lib$date_format_013 ie 01/JAN/89
and to lib$time_format_011 ie 09:13 AM,
for more information on the date and time routines
see pages 3-10 through 3-13 in the V5.0 Run Time Library Manual */
sts$value = lib$init_date_time_context(context,component,init_string);
if ^sts$success
then signal vaxcondition(sts$value);
/*format the supplied date and time using the context giving
in the above call to lib$init_date_time_context*/
sts$value = lib$format_date_time(date_string,binary_date,context,,);
if ^sts$success
then signal vaxcondition(sts$value);
put skip list(date_string);
end calc;
|
buy online or call 1.800.AT.COMPAQ
|
|