#!/usr/bin/env perl

BEGIN {
   if ( $#ARGV >= 0 ) {
      print STDERR <<'ENDOFHELP';

   Usage:

   now

   now returns a unique 14-digit numeric string in the form of YYYYMMDDHHmmss
   based on the current date and time after a random-length sleep.

   It creates a lockfile in \$ENV{HOME} to prevent two 'now' processes from running
   simultaneously and sleeps a random number of seconds before retrying if a lock
   encountered



ENDOFHELP
   $die_away = 1;
   }

   use FindBin;

# This module contains the dirname() subroutine.

   use File::Basename;

# If default GEOS DAS path, set path to parent directory of directory where this
# script resides.

      $GEOSDAS_PATH = dirname( $FindBin::Bin );

# Set name of the bin directory to search for other programs needed by this one.

   $BIN_DIR = "$GEOSDAS_PATH/bin";

# Get the name of the directory where this script resides.  If it is different

# than BIN_DIR, then this directory will also be included in the list of
# directories to search for modules and programs.

   $PROGRAM_PATH = $FindBin::Bin;

# Now allow use of any modules in the bin directory, and (if not the same) the
# directory where this program resides.  (The search order is set so that
# the program's directory is searched first, then the bin directory.)

   if ( $PROGRAM_PATH ne $BIN_DIR ) {
      @SEARCH_PATH = ( $PROGRAM_PATH, $BIN_DIR );
   } else {
      @SEARCH_PATH = ( $BIN_DIR );
   }

}       # End BEGIN

# Any reason to exit found during the BEGIN block?

if ( $die_away == 1 ) {
   exit 1;
}

# Include the directories to be searched for required modules.

use lib ( @SEARCH_PATH );

# Set the path to be searched for required programs.
                                                    $ENV{'PATH'} = join( ':', @SEARCH_PATH, $ENV{'PATH'} );

# This module contains the rget() subroutine.

use Manipulate_time;

$now  = now();

print "$now\n";

# Change the return code so that 0 indicates success.  (Scripts and script wrappers
# return 0 on success, (unix convention), perl subroutines return "true" on success.)

exit ! $rget_retcode;

