RTClib, set time using the unix time stamp?

Is there a way to set the time in the Adafruit or Jeelabs RTClib using the unix time stamp?

In the library they define different classes:

  • class DateTime = Simple general-purpose date/time class (no TZ / DST / leap second handling!)
  • class TimeSpan = which can represent changes in time with seconds accuracy
  • different classes for abstracting different RTC hardware (RTC_DS1307, RTC_DS3231, RTC_PCF8523)

if you look at the DateTime constructor you’ll see you can pass the unix time stamp to build a dateTime instance

// DateTime implementation - ignores time zones and DST changes
// NOTE: also ignores leap seconds, see http://en.wikipedia.org/wiki/Leap_second

DateTime::DateTime (uint32_t t) {
  t -= SECONDS_FROM_1970_TO_2000;    // bring to 2000 timestamp from 1970

Once you have your DateTime object, every type of RTC they support has a method
static void adjust(const DateTime& dt);
which takes a DateTime instance as parameter and uses its value to set the clock’s time

so seems i’ts not too difficult to combine the 2 to get what you want

ok I go this way. Thanks