Skip to content

Commit

Permalink
toolsa/DateTime, Radx/RadxTime - adding setToNever() method
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dixon committed Dec 13, 2023
1 parent 491d906 commit 1a5dd7b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
24 changes: 22 additions & 2 deletions codebase/libs/Radx/src/Radx/RadxTime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
//
// Utility class for manipulating date/time
//
// Terri L. Betancourt RAP, NCAR, Boulder, CO, 80307, USA
// January 1999
// Based on toolsa DateTime class
//
///////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -166,6 +165,27 @@ void RadxTime::clear()
_init();
}

/////////////////////////////
/// Set to current time

void RadxTime::setToNow()

{
struct timeval tv;
gettimeofday(&tv, NULL);
_uTime = tv.tv_sec;
_subSec = tv.tv_usec / 1.0e6;
}

/////////////////////////////
/// Set invalid

void RadxTime::setToNever()

{
set(NEVER);
}

///////////////////////////////////
// set based on spec

Expand Down
11 changes: 10 additions & 1 deletion codebase/libs/Radx/src/include/Radx/RadxTime.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
//
// RadxTime
//
// Utility class for manipulating date/time
// Utility class for manipulating date/time.
// Originally based on toolsa DateTime class.
//
////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -113,6 +114,14 @@ public:
/// Clear - set to Jan 1 1970

void clear();

/// sets to subsec precision, using getTimeOfDay()

void setToNow();

/// set to invalid

void setToNever();

/// Set from time_t

Expand Down
2 changes: 2 additions & 0 deletions codebase/libs/toolsa/src/include/toolsa/DateTime.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public:

void setToNow(); // sets to subsec precision, using getTimeOfDay()

void setToNever(); // sets to invalid

void set(time_t when);

void set(time_t when, double subSec);
Expand Down
7 changes: 7 additions & 0 deletions codebase/libs/toolsa/src/utim/DateTime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,17 @@ void
_subSec = tv.tv_usec / 1.0e6;
}

void
DateTime::setToNever()
{
set(NEVER);
}

void
DateTime::set(time_t when)
{
_uTime = when;
_subSec = 0;
setLeadDeltaTime(NULL);
}

Expand Down

0 comments on commit 1a5dd7b

Please sign in to comment.