gltimefix
Description
gltimefix is a utility designed to address time-related issues within JCU GLORIA record files. Its primary function is to constrain the Julian day of records to a specified range and to correct records where the year is not 1970, which can be a base year for time calculations in some systems.
Usage
gltimefix <filename>
Arguments
| Option | Description |
|---|---|
<filename> | Required. The path to the JCU GLORIA file to be time-fixed. |
How It Works
- File Opening: The tool opens the specified GLORIA file in read-write mode.
- File Length Determination: It determines the total number of records in the file.
- Record-by-Record Processing: The tool iterates through each record in the GLORIA file:
- It reads each record into
glo_rec. - It calls the
constrain_dayfunction to perform time validation and correction. - If
constrain_dayindicates a change was made, the modifiedglo_recis written back to the file.
- It reads each record into
constrain_dayFunction:- This function takes
minandmaxJulian day values (hardcoded as 311 and 312 in the provided source). - It converts the
glo_rec.header.time(Unix timestamp) to astruct tmusinggmtime. - Julian Day Constraint: If the recordβs Julian day (
tm1->tm_yday + 1) falls outside theminandmaxrange, it adjuststm1->tm_ydaytolast_day - 1(wherelast_dayis dynamically updated from valid records) and sets abad_dayflag. - Year Correction: If the recordβs year (
tm1->tm_year) is not1970, it sets abad_yearflag. - Apply Corrections: If either
bad_dayorbad_yearis set:- It reconstructs the
glo_rec.header.timeusingstdtime_from_jul_day, forcing the year to 1970 and using the potentially corrected Julian day. - It returns
1to indicate a modification was made.
- It reconstructs the
- If no issues are found, it updates
last_dayand returns0.
- This function takes
- Output: Corrected records are written back to the input GLORIA file.