OpenVMS Source-Code Demos

WCSM_GET_MIME_TIME.FUN

	function string wcsm_get_mime_time					!
	!==========================================================================================
	! Title  : wcsm_get_mime_time_xxx.fun (see: RFC 822)
	! Author : Neil Rieck
	! History:
	! ver  who when   what
	! ---- --- ------ --------------------------------------------------------------------------
	!    3 NSR 090514 dervived from wcsm_get_gmt_time_2.fun (Dave McNeil)
	!    4 NSR 110316 added documentation reguarding logical SYS$TIMEZONE_DIFFERENTIAL
	!		  tweaked the code
	!==========================================================================================
	! Purpose:
	!		returns a string like this:
	!			Thu, 14 May 2009 12:01:01 -0400
	! Dependancies:
	!		wcsm_trnlnm must be included in calling application's source.
	!==========================================================================================
	option type=explicit							!
	!
	!	Our variables
	!
	declare basic$quadword	quad_time					!
	declare long		rc%, dt_context%, component%			!
	declare double		data_to_test, seconds, minutes, hours, yada	!
	declare string		result$, tz_diff$, tz_name$			!
	!
	!	Include some system stuff
	!
	%include "starlet"          %from %library "sys$library:basic$starlet"
	%include "lib$routines"     %from %library "sys$library:basic$starlet"
	%include "$libdtdef"        %from %library "sys$library:basic$starlet"
	!
	!	External stuff
	!
	external string function wcsm_trnlnm(string, string)			!
	!
	!	Note: these system logicals will only change if "set_vms_logicals" is added to file TCPWARE:NTP.CONF
	!
	tz_name$ = wcsm_trnlnm("SYS$TIMEZONE_NAME"        , "LNM$SYSTEM_TABLE")	!
	tz_name$ = "EDT"	if tz_name$ = ""				!
	!
	tz_diff$ = wcsm_trnlnm("SYS$TIMEZONE_DIFFERENTIAL", "LNM$SYSTEM_TABLE")	!
	tz_diff$ = "-14400"	if tz_diff$ = ""				! default to EDT
	!
	!	Note: the value of SYS$TIMEZONE_DIFFERENTIAL is given in seconds before/after GMT
	!
	!	  data	 HHMM	zone		zone	zone	zone	notes
	!	------	-----	--------	----	----	----	----------------
	!	-18000	-0500	UTC-5		EST			Eastern
	!	-14400	-0400	UTC-4		EDT	AST		Eastern/Atlantic
	!	-10800	-0300	UTC-3			ADT		Atlantic
	!	-12600	-0330	UTC-3:30			NST	(Newfoundland)
	!	 -9000	-0230	UTC-2:30			NDT	(Newfoundland)
	!
	when error in								!
	    data_to_test = real(tz_diff$, DOUBLE)				!
	    seconds = abs(data_to_test)						! make sure this is positive
	    hours = integer(seconds / 3600.0)					! compute hours
!~~~	    print using "<0>#"; hours;						x
	    yada = seconds - (hours * 3600.0)					! compute remainder
	    minutes = integer(yada / 60.0)					!
!~~~	    print using "<0>#"; minutes						x
	    !
	    tz_diff$ =	format$(hours,	"<0>#")	+				&
			format$(minutes,"<0>#")					!
	    !
	    if data_to_test < 0 then						!
		tz_diff$ = "-"+ tz_diff$					!
	    else								!
		tz_diff$ = "+"+ tz_diff$					!
	    end if								!
	use									! oops
	    tz_diff$ = tz_name$							! use this older format
	end when								!
	!
	rc% = sys$gettim(quad_time)						! get current system time.
	dt_context% = 0								!
	component% = LIB$K_OUTPUT_FORMAT					!
	rc% = lib$init_date_time_context(dt_context%, component%, "|!WAC, !D0 !MAAC !Y4|!H04:!M0:!S0|")
	rc% = lib$format_date_time(result$, quad_time, dt_context%,,)		!
	result$ = result$ +" "+ tz_diff$					!
	!
	wcsm_get_mime_time = result$						!
	end function 								!

Back to OpenVMS
Back to OpenVMS Demo Index
Back to Home
Neil Rieck
Kitchener - Waterloo - Cambridge, Ontario, Canada.