Skip to content

Commit

Permalink
Fixed incorrect time stamp conversion for OWM and aprs.fi - thank you…
Browse files Browse the repository at this point in the history
… DB4BIN
  • Loading branch information
joergschultzelutter committed Mar 30, 2021
1 parent 3ca4497 commit 5fe6147
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/TECHNICAL_DETAILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ A decaying cache for __outgoing__ messages to the user is currently not implemen
- Openstreetmap category data:
- MPAD honors OSM's [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim) by artificially delaying requests to OSM. Whenever you request OSM category data and you have requested more than one result, each follow-up request of that same command experiences an artificial delay between 1.2 and 3.0 seconds (random value). Therefore, requesting 5 results can take between 6 and 15 secs (excluding any additional delays for the outgoing APRS messages)
- General:
- This program is single-threaded and will take care of one message at a time. Parallel processing of messages is not implemented.
- APRS 'TOCALL' identifier is currently still set to default 'APRS' (see WXBOT implementation); in the long run, MPAD needs its own identifier (see http://www.aprs.org/aprs11/tocalls.txt)
- Call signs which deviate from a 'normal' call sign pattern may not be recognised (e.g. APRS bot call signs etc) at all times. In this case, the program may not know what to do and will perform a fallback to its default mode: generate a wx report for the user's call sign.
- Keyword-less requests or request data that was supplied in an incorrect manner is prone to misinterpretation. Mainly, that misinterpretation happens if you request a wx report for a city whose name consists of multiple parts - and you forget to specify state or country code. Example: a request for the German city of ```Bad Driburg``` (note the missing state/country data) would get misinterpreted as METAR request for the airport of Barksdale, LA (IATA code BAD / ICAO code KBAD). Specify the wx report in the official format (```Bad Driburg;de```) and you'll be fine. MPAD will notice the format qualifiers and -despite having a match on the valid IATA Code- will interpret the data as a Wx request. Nevertheless, other side effects may happen.
Expand Down
2 changes: 1 addition & 1 deletion src/aprsdotfi_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_position_on_aprsfi(aprsfi_callsign: str, aprsdotfi_api_key: str):
altitude = float(json_content["entries"][0]["altitude"])
if "lasttime" in json_content["entries"][0]:
_mylast = float(json_content["entries"][0]["lasttime"])
lasttime = datetime.fromtimestamp(_mylast)
lasttime = datetime.utcfromtimestamp(_mylast)

return success, latitude, longitude, altitude, lasttime, aprsfi_callsign

Expand Down
2 changes: 1 addition & 1 deletion src/mpad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# Program version
#
mpad_version: str = "0.22"
mpad_version: str = "0.23"
#
###########################
# Constants, do not change#
Expand Down
10 changes: 5 additions & 5 deletions src/openweathermap_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def parse_daily_weather_from_openweathermapdotorg(
# If we have a time stamp, then let's provide a real date to the user
if "dt" in weather_tuple:
w_dt = weather_tuple["dt"]
tmp_dt = datetime.fromtimestamp(w_dt)
tmp_dt = datetime.utcfromtimestamp(w_dt)
when_text = datetime.strftime(tmp_dt, "%d-%b-%y")
if "sunrise" in weather_tuple:
w_sunrise = weather_tuple["sunrise"]
Expand Down Expand Up @@ -321,19 +321,19 @@ def parse_daily_weather_from_openweathermapdotorg(

# Sunrise and Sunset
if w_sunset and w_sunrise:
tmp1 = datetime.fromtimestamp(w_sunrise)
tmp2 = datetime.fromtimestamp(w_sunset)
tmp1 = datetime.utcfromtimestamp(w_sunrise)
tmp2 = datetime.utcfromtimestamp(w_sunset)
weather_forecast_array = make_pretty_aprs_messages(
f"sunrise/set {tmp1.hour:02d}:{tmp1.minute:02d}/{tmp2.hour:02d}:{tmp2.minute:02d}UTC",
weather_forecast_array,
)
elif w_sunrise and not w_sunset:
tmp = datetime.fromtimestamp(w_sunrise)
tmp = datetime.utcfromtimestamp(w_sunrise)
weather_forecast_array = make_pretty_aprs_messages(
f"sunrise {tmp.hour}:{tmp.minute}UTC", weather_forecast_array
)
elif w_sunset and not w_sunrise:
tmp = datetime.fromtimestamp(w_sunset)
tmp = datetime.utcfromtimestamp(w_sunset)
weather_forecast_array = make_pretty_aprs_messages(
f"sunset {tmp.hour}:{tmp.minute}UTC", weather_forecast_array
)
Expand Down

0 comments on commit 5fe6147

Please sign in to comment.