I was thinking about this today and thought of another way to select the
return format.  What if the routines that returned a VMS time value had an
extra argument indicating what format to return it in?  Constants for the
format argument could be provided by the module.  The possible formats
could include 8 byte string (packed format), integer (if 64 bit integer
support is built into perl), or float.  Does this sound like a more usable
interface?

For example:
    $tm1 = gettim(VMSTM_PACK);
    $tm2 = bintim('31-DEC-2012 18:00', VMSTM_FLOAT);

It was suggested to return a list of values but then the caller needs to
know which entry in the returned list is in the desired format.  It also
means returning multiple values when the caller probably only wants one.

On Mon, Dec 24, 2012 at 5:19 PM, Thomas Pfau <tfp...@gmail.com> wrote:

> I wrote a time module that interfaces to the VMS time system services -
> $BINTIM, $ASCTIM, $GETTIM, and $NUMTIM.  I also had a replacement routines
> for $ASCTIM, $BINTIM and $GETTIM that could be used on non-VMS platforms.
>
> Currently it accepts and returns VMS time buffers as 8 byte strings but I
> was thinking of allowing numeric values to be passed if perl was built with
> 64 bit integer support.  I could detect the input format by using
> SvIOK/SvPOK.  The problem I have is determining how the user wants the
> information returned.
>
> Current interface ($now and $bin are 8 byte strings containing the time):
>       $now = gettim();
>       $bin = bintim('01-jan-2010 12:00:00.00');
>       $asc = asctim($bin);
>       ($year, $month, $day, $hr, $mn, $sc, $cc) = numtim($bin);
>
> I'm thinking of using an optional additional argument on gettim and bintim
> that would be written with the 8 byte string and have the routines return
> the time as an integer if perl is built with 64 bit integers.  I could try
> to interface to the bigint module and return a bigint value if 64 bit
> integers aren't available.
>
> Would anyone find this useful?  Any comments on the interface?
>
> --
> Thomas Pfau
> tfp...@gmail.com
> http://www.linkedin.com/in/thomaspfau
> http://nbpfaus.net/~pfau/




-- 
Thomas Pfau
tfp...@gmail.com
http://www.linkedin.com/in/thomaspfau
http://nbpfaus.net/~pfau/

Reply via email to