Skip to content

Commit

Permalink
bugfix for negative time offset and example bat comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evogelsa committed Jan 7, 2021
1 parent 091fe21 commit 9e83be6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/replace_mission.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ rename "Missions\backups\mission.miz" "%d%_%t%_mission.miz"

:: Move mission into realweather working directory and move updated mission
:: back into missions folder
move "Missions\mission.miz" "realweather\mission.miz" :: realweather expects "mission.miz"
cd realweather :: CWD must be parent directory of binary
move "Missions\mission.miz" "realweather\mission.miz"
cd realweather
call realweather.exe
cd ..
move "realweather\realweather.miz" "Missions\mission.miz"
14 changes: 3 additions & 11 deletions miz/miz.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,16 @@ func windSpeed(targHeight, refHeight, refSpeed, roughness float64) float64 {
return refSpeed * ((math.Log(targHeight / roughness)) / (math.Log(refHeight / roughness)))
}

// sysTime returns system time in seconds
func sysTime() int {
t := time.Now()
return ((t.Hour()*60)+t.Minute())*60 + t.Second()
}

// parseTime returns system time in seconds with offset defined in config file
func parseTime() int {
// parse config file for parameters
config := util.ParseConfig()

// get system time in second
t := sysTime()
// add hour offset from configuration file
t += config.HourOffset * 60 * 60
t %= 24 * 60 * 60
t := time.Now()
t.Add(time.Duration(config.HourOffset) * time.Hour)

return t
return ((t.Hour()*60)+t.Minute())*60 + t.Second()
}

// parseDate returns year, month, day from METAR observed
Expand Down

0 comments on commit 9e83be6

Please sign in to comment.