Skip to content

Commit

Permalink
getHour() 1-12
Browse files Browse the repository at this point in the history
fix #40
  • Loading branch information
fbiego committed Mar 17, 2024
1 parent e06f6b4 commit 56c7cca
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.py
6 changes: 5 additions & 1 deletion ESP32Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int ESP32Time::getMinute(){
@brief get the current hour as int
@param mode
true = 24 hour mode (0-23)
false = 12 hour mode (0-12)
false = 12 hour mode (1-12)
*/
int ESP32Time::getHour(bool mode){
struct tm timeinfo = getTimeStruct();
Expand All @@ -293,6 +293,10 @@ int ESP32Time::getHour(bool mode){
{
return timeinfo.tm_hour-12;
}
else if (hour == 0)
{
return 12; // 12 am
}
else
{
return timeinfo.tm_hour;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ getEpoch() // (unsigned long) 1609459200
getLocalEpoch() // (unsigned long) 1609459200 // local epoch without offset
getSecond() // (int) 38 (0-59)
getMinute() // (int) 24 (0-59)
getHour() // (int) 3 (0-12)
getHour() // (int) 3 (1-12)
getHour(true) // (int) 15 (0-23)
getAmPm() // (String) PM
getAmPm(true) // (String) pm
Expand Down
2 changes: 1 addition & 1 deletion examples/esp32_time/esp32_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void loop() {
// Serial.println(rtc.getEpoch()); // (long) 1609459200
// Serial.println(rtc.getSecond()); // (int) 38 (0-59)
// Serial.println(rtc.getMinute()); // (int) 24 (0-59)
// Serial.println(rtc.getHour()); // (int) 3 (0-12)
// Serial.println(rtc.getHour()); // (int) 3 (1-12)
// Serial.println(rtc.getHour(true)); // (int) 15 (0-23)
// Serial.println(rtc.getAmPm()); // (String) pm
// Serial.println(rtc.getAmPm(true)); // (String) PM
Expand Down
2 changes: 1 addition & 1 deletion examples/esp32_time_multiple/esp32_time_multiple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void loop() {
// Serial.println(rtc.getEpoch()); // (unsigned long) 1609459200
// Serial.println(rtc.getSecond()); // (int) 38 (0-59)
// Serial.println(rtc.getMinute()); // (int) 24 (0-59)
// Serial.println(rtc.getHour()); // (int) 3 (0-12)
// Serial.println(rtc.getHour()); // (int) 3 (1-12)
// Serial.println(rtc.getHour(true)); // (int) 15 (0-23)
// Serial.println(rtc.getAmPm()); // (String) pm
// Serial.println(rtc.getAmPm(true)); // (String) PM
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP32Time",
"version": "2.0.5",
"version": "2.0.6",
"keywords": "Arduino, ESP32, Time, Internal RTC",
"description": "An Arduino library for setting and retrieving internal RTC time on ESP32 boards",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32Time
version=2.0.5
version=2.0.6
author=fbiego
maintainer=fbiego
sentence=Set and retrieve internal RTC time on ESP32 boards.
Expand Down

0 comments on commit 56c7cca

Please sign in to comment.