summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/MTS_IO_CellularRadio.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 3ce97ec..1c385ae 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -581,6 +581,7 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi
std::string sCmd("AT+CCLK?");
std::string sResult = sendCommand(sCmd);
size_t end = sResult.find(ICellularRadio::RSP_OK);
+
if (end == std::string::npos) {
printWarning("%s| Unable to get Time from radio using command [%s]", m_sName.c_str(), sCmd.c_str());
return FAILURE;
@@ -605,37 +606,15 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi
return FAILURE;
}
- //The Date format is YY/MM/DD -> Change to MM/DD/YY
- sDate = vDateParts[1] + "/" + vDateParts[2] + "/" + vDateParts[0];
+ // Append "20" to the year. format is YYYY-MM-DD
+ sDate = "20" + vDateParts[0] + "-" + vDateParts[1] + "-" + vDateParts[2];
vParts = MTS::Text::split(vParts[1], '-');
- if(vParts.size() != 2) {
+ if(vParts.size() != 1) {
printWarning("%s| Unable to parse Time from response [%s]", m_sName.c_str(), sResult.c_str());
return FAILURE;
}
sTime = vParts[0];
-
- int32_t iZoneUnits; //the difference, expressed in quarters of an hour, between the local time and GMT
- if(!MTS::Text::parse(iZoneUnits, MTS::Text::strip(vParts[1], '+'))) {
- printWarning("%s| Unable to parse Time Zone from response [%s]", m_sName.c_str(), sResult.c_str());
- return FAILURE;
- }
-
- int32_t iZone = iZoneUnits/4; //Divide by 4 to get hours difference
- int32_t iZonePartial = (iZoneUnits % 4) * 15; //Remainder in minutes
- std::string sPlusSign = "+";
- if(iZonePartial < 0) {
- //Remove negative sign from partial and clear plus sign component
- iZonePartial *= -1;
- sPlusSign = "";
- }
- std::stringstream ss;
- ss << sPlusSign << iZone;
- if(iZonePartial != 0) {
- ss << ":" << iZonePartial;
- }
-
- sTimeZone = ss.str();
return SUCCESS;
} else {