Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ void refreshCache(time_t t) {
}
}

int hour() { // the hour now
uint8_t hour() { // the hour now
return hour(now());
}

int hour(time_t t) { // the hour for the given time
uint8_t hour(time_t t) { // the hour for the given time
refreshCache(t);
return tm.Hour;
}

int hourFormat12() { // the hour now in 12 hour format
uint8_t hourFormat12() { // the hour now in 12 hour format
return hourFormat12(now());
}

int hourFormat12(time_t t) { // the hour for the given time in 12 hour format
uint8_t hourFormat12(time_t t) { // the hour for the given time in 12 hour format
refreshCache(t);
if( tm.Hour == 0 )
return 12; // 12 midnight
Expand All @@ -85,47 +85,47 @@ uint8_t isPM(time_t t) { // returns true if PM
return (hour(t) >= 12);
}

int minute() {
uint8_t minute() {
return minute(now());
}

int minute(time_t t) { // the minute for the given time
uint8_t minute(time_t t) { // the minute for the given time
refreshCache(t);
return tm.Minute;
}

int second() {
uint8_t second() {
return second(now());
}

int second(time_t t) { // the second for the given time
uint8_t second(time_t t) { // the second for the given time
refreshCache(t);
return tm.Second;
}

int day(){
uint8_t day(){
return(day(now()));
}

int day(time_t t) { // the day for the given time (0-6)
uint8_t day(time_t t) { // the day for the given time (0-6)
refreshCache(t);
return tm.Day;
}

int weekday() { // Sunday is day 1
uint8_t weekday() { // Sunday is day 1
return weekday(now());
}

int weekday(time_t t) {
uint8_t weekday(time_t t) {
refreshCache(t);
return tm.Wday;
}

int month(){
uint8_t month(){
return month(now());
}

int month(time_t t) { // the month for the given time
uint8_t month(time_t t) { // the month for the given time
refreshCache(t);
return tm.Month;
}
Expand Down Expand Up @@ -318,4 +318,4 @@ void setSyncProvider( getExternalTime getTimeFunction){
void setSyncInterval(time_t interval){ // set the number of seconds between re-sync
syncInterval = (uint32_t)interval;
nextSyncTime = sysTime + syncInterval;
}
}
28 changes: 14 additions & 14 deletions TimeLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@ typedef time_t(*getExternalTime)();

/*============================================================================*/
/* time and date functions */
int hour(); // the hour now
int hour(time_t t); // the hour for the given time
int hourFormat12(); // the hour now in 12 hour format
int hourFormat12(time_t t); // the hour for the given time in 12 hour format
uint8_t hour(); // the hour now
uint8_t hour(time_t t); // the hour for the given time
uint8_t hourFormat12(); // the hour now in 12 hour format
uint8_t hourFormat12(time_t t); // the hour for the given time in 12 hour format
uint8_t isAM(); // returns true if time now is AM
uint8_t isAM(time_t t); // returns true the given time is AM
uint8_t isPM(); // returns true if time now is PM
uint8_t isPM(time_t t); // returns true the given time is PM
int minute(); // the minute now
int minute(time_t t); // the minute for the given time
int second(); // the second now
int second(time_t t); // the second for the given time
int day(); // the day now
int day(time_t t); // the day for the given time
int weekday(); // the weekday now (Sunday is day 1)
int weekday(time_t t); // the weekday for the given time
int month(); // the month now (Jan is month 1)
int month(time_t t); // the month for the given time
uint8_t minute(); // the minute now
uint8_t minute(time_t t); // the minute for the given time
uint8_t second(); // the second now
uint8_t second(time_t t); // the second for the given time
uint8_t day(); // the day now
uint8_t day(time_t t); // the day for the given time
uint8_t weekday(); // the weekday now (Sunday is day 1)
uint8_t weekday(time_t t); // the weekday for the given time
uint8_t month(); // the month now (Jan is month 1)
uint8_t month(time_t t); // the month for the given time
int year(); // the full four digit year: (2009, 2010 etc)
int year(time_t t); // the year for the given time

Expand Down