Skip to content

Commit

Permalink
Fixed get() and secondstime() refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Jul 30, 2010
1 parent 7c9a955 commit d59bb4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions RTClib.cpp
Expand Up @@ -105,8 +105,8 @@ DateTime::DateTime (const char* date, const char* time) {
}

uint8_t DateTime::dayOfWeek() const {
uint16_t day = secondstime() / SECONDS_PER_DAY;
return (day + 6) % 7; // Jan 1, 2000 is a Saturday, i.e. returns 6
uint16_t day = unixtime() / SECONDS_PER_DAY;
return (day + 4) % 7; // Jan 1, 2000 is a Thursday, i.e. returns 4
}

uint32_t DateTime::unixtime(void) const {
Expand Down Expand Up @@ -175,7 +175,7 @@ DateTime RTC_DS1307::now() {
long RTC_Millis::offset = 0;

void RTC_Millis::adjust(const DateTime& dt) {
offset = dt.secondstime() - millis() / 1000;
offset = dt.unixtime() - millis() / 1000;
}

DateTime RTC_Millis::now() {
Expand Down
12 changes: 6 additions & 6 deletions examples/datecalc/datecalc.pde
Expand Up @@ -19,10 +19,10 @@ void showDate(const char* txt, const DateTime& dt) {
Serial.print(dt.second(), DEC);

Serial.print(" = ");
Serial.print(dt.get());
Serial.print(dt.unixtime());
Serial.print("s / ");
Serial.print(dt.get() / 86400L);
Serial.print("d since 2000");
Serial.print(dt.unixtime() / 86400L);
Serial.print("d since 1970");

Serial.println();
}
Expand Down Expand Up @@ -51,13 +51,13 @@ void setup () {
DateTime dt6 (2009, 12, 27, 0, 0, 0);
showDate("dt6", dt6);

DateTime dt7 (dt6.get() + 3600); // one hour later
DateTime dt7 (dt6.unixtime() + 3600); // one hour later
showDate("dt7", dt7);

DateTime dt8 (dt6.get() + 86400L); // one day later
DateTime dt8 (dt6.unixtime() + 86400L); // one day later
showDate("dt8", dt8);

DateTime dt9 (dt6.get() + 7 * 86400L); // one week later
DateTime dt9 (dt6.unixtime() + 7 * 86400L); // one week later
showDate("dt9", dt9);
}

Expand Down
6 changes: 3 additions & 3 deletions examples/softrtc/softrtc.pde
Expand Up @@ -27,11 +27,11 @@ void loop () {
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" seconds since 2000: ");
Serial.println(now.get());
Serial.print(" seconds since 1970: ");
Serial.println(now.unixtime());

// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.get() + 7 * 86400L + 30);
DateTime future (now.unixtime() + 7 * 86400L + 30);

Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Expand Down

0 comments on commit d59bb4f

Please sign in to comment.