Time/ Date manipulation

I have time stamps from two different instruments in different formats that I am trying to align (so that I can later average out data to account for different time resolutions). The first is in a wave in hours with no specified date (ex: 17.12345 h) in UTC, and the second is in wave of MM:DD:YYYY hr:min:sec (ex: 6/21/2018 12:34:56.789) in pacific time. I would like to throw out the date stamp on the second wave and generate an output wave in seconds for each instrument.

The best way I can see to do this would be to have two separate functions to deal with each time. I am new to igor and I'm having a hard time with syntax, I would appreciate any and all suggestions. I have included the files below.

 

Thanks

Cabin_time.ibw (91.02 KB) TimeWave.ibw (28.98 MB)

To remove the date component of an Igor date/time value, execute something like this:

wave -= Date2Secs(1904,1,1)  // Remove date component

For details, execute:

DisplayHelpTopic "Date/Time Waves"

 

Correction: It should be:

wave -= Date2Secs(2018, 06, 21)  // Remove date component

More generally:

// RemoveDateFromDateTimeWave(w)
// w is assumed to contain Igor date/time values in increasing order.
// Example:
//      Make/O/D/N=3 dtWave
//      SetScale d, 0, 0, "dat", dtWave         // Mark as date/time wave
//      dtWave[0] = {Date2Secs(2018,06,21)+5000}
//      dtWave[1] = {Date2Secs(2018,06,21)+10000}
//      dtWave[2] = {Date2Secs(2018,06,21)+15000}
//      Edit dtWave
//      ModifyTable format(dtWave)=8                // Display as date/time values
//      RemoveDateFromDateTimeWave(dtWave)
//      ModifyTable format(dtWave)=7            // Display as time values
Function RemoveDateFromDateTimeWave(w)
    Wave w              // Assumed to contain Igor date/time values in increasing order
   
    Variable dateTime0 = w[0]
    String date0Str = Secs2Date(dateTime0, -2)      // In YYYY-MM-DD format
    Variable year, month, day
    sscanf date0Str, "%d-%d-%d", year, month, day
    Variable date0Secs = Date2Secs(year, month, day)
    w -= date0Secs
End

After the RemoveDateFromDateTimeWave, the times are displayed in the table as, e.g., "1904-01-01 01:23:20". Since 1904-01-01 is the base of the Igor date/time system, 1904-01-01 is represented as zero seconds.

 

hrodstein,

I apologize for the late response, your function worked perfectly for removing the date. I now have hh:mm:ss.xxxx format that I would like to get into seconds since 1904-01-01. Based on some of your other comments, it seems like this is how igor stores the times anyways, but how should I go about displaying those values?

Thank you for your help.