IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38685


Ignore:
Timestamp:
Aug 28, 2015, 8:56:26 AM (11 years ago)
Author:
eugene
Message:

allow date to report seconds as a double

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/opihi/cmd.basic/date.c

    r27435 r38685  
    33int date (int argc, char **argv) {
    44 
    5   int N, SECONDS, REFTIME;
     5  int N, SECONDS;
     6  double REFTIME;
    67  struct timeval now;
    78  char *tstring = NULL;
     
    1617  }
    1718
    18   REFTIME = 0;
     19  REFTIME = 0.0;
    1920  if ((N = get_argument (argc, argv, "-reftime"))) {
    2021    remove_argument (N, &argc, argv);
    21     REFTIME = atoi (argv[N]);
     22    REFTIME = atof (argv[N]);
    2223    remove_argument (N, &argc, argv);
    2324  }
     
    3738  gettimeofday (&now, NULL);
    3839  if (SECONDS) {
     40    double nowSec = now.tv_sec + 1e-6*now.tv_usec;
    3941    if (varName) {
    40       set_int_variable (varName, now.tv_sec - REFTIME);
     42      set_variable (varName, nowSec - REFTIME);
    4143    } else {
    42       gprint (GP_ERR, "%d\n", (int) now.tv_sec - REFTIME);
     44      gprint (GP_ERR, "%.12g\n", nowSec - REFTIME);
    4345    }
    4446  } else {
Note: See TracChangeset for help on using the changeset viewer.