NAME

VMS::Time - Manipulate OpenVMS binary time values

SYNOPSIS

use VMS::Time ':all';

$now = gettim();
$bin = bintim('01-jan-2010 12:00:00.00');
$asc = asctim($bin);
($year, $month, $day, $hr, $mn, $sc, $cc) = numtim($bin);
$unix = vms_to_epoch($bin);
$vms = epoch_to_vms(time());

DESCRIPTION

These functions provide access to the OpenVMS time system services SYS$GETTIM, SYS$BINTIM, SYS$ASCTIM, and SYS$NUMTIM. Also provided are functions for converting between OpenVMS binary times and unix epoch time values.

EXPORT

None by default. Any function or constant may be imported by name. All functions can be imported using the tag ':routines'. All constants can be imported using the tag ':constants'. Routines and constants can be imported using the tag ':all'.

OVERVIEW

VMS::Time can accept and return VMS times in various formats depending upon the platform and how perl was built. The routines that return VMS time values accept a return mode argument that determines the format for the returned value. Constants are defined for the return modes as follows.

PACK - Pack format (default)

Returns the time as a string containing an 8 byte OpenVMS time value.

LONGINT - Integer

Returns the time value as an integer. This is only supported if perl was built with support for long integers.

FLOAT - Floating point

Returns the time value as a floating point number. Precision may be lost especially if perl was not built with support for long doubles. FLOAT is not supported on VAX systems.

HEX - Hex string

Returns the time value as a hex encoded string with a leading '0x'.

BIGINT - Math::BigInt

Returns the time value as a Math::BigInt object. Math::BigInt must have been previously loaded.

The format for input VMS time values is deduced from the attributes of the perl variable passed to the function. If the variable contains an integer, LONGINT format is assumed. If the variable containes a floating point value, FLOAT format is assumed. If the variable is a string with a leading '0x', HEX format is assumed. If the variable is an 8 byte string, PACK format is assumed. If the variable is a Math::BigInt object, BIGINT format is assumed.

FUNCTIONS

bintim - convert ascii time string to binary

$bin = bintim('01-jan-2010 12:00:00.00'[,$retmode]);

Converts the time string to a VMS time value. $retmode indicates the format for the returned value as described in the overview section.

asctim - convert binary time to ascii string

$text = asctim([$bin])

Converts an OpenVMS time to its textual presentation. If a binary time is not provided, the current time is used.

gettim - get current time as binary

$bin = gettim([$retmode]);

Returns the current time. $retmode specifies the format of the returned value as described in the overview section.

numtim - get current time as array or convert binary time to array

@a = numtim();	    # current time
@a = numtim($bin);	    # supplied time value

Returns an array of numeric values representing the current time. The values are returned in the order year, month, day, hour, minute, second, hundredth of seconds.

If no binary time value is provided the current time is used.

epoch_to_vms - convert unix epoch time value to vms time

$bin = epoch_to_vms($tm);

Converts the provided unix time value to OpenVMS binary time format.

vms_to_epoch - convert vms time to unix epoch time value

$tm = vms_to_epoch($bin);

Converts an 8 byte OpenVMS binary time to a unix time value.

SEE ALSO

See the OpenVMS System Services Reference Manual for descriptions of the referenced system services.

AUTHOR

Thomas Pfau, <tfpfau@gmail.com<gt>

COPYRIGHT AND LICENSE

VMS::Time is Copyright (C) 2013 by Thomas Pfau

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This module is distributed in the hope that it will be useful but it is provided "as is"and without any express or implied warranties.