AVR Standard C Time Library - bad epoch return

Hi. I want to use AVR Standard C Time Library for convert time to epoch, but it’s not working and I can’t find the fix. This is my code:

#include <ephemera_common.h>
#include <time.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
  time_t epoch = tmConvert_t(2004, 1, 1, 45, 13, 33);
  Serial.println((time_t)-1);
  Serial.println(epoch);
}


time_t tmConvert_t(int YYYY, byte MM, byte DD, byte hh, byte mm, byte ss)
{
  struct tm tmSet;
  tmSet.tm_year = YYYY - 1900;
  tmSet.tm_mon = MM - 1;
  tmSet.tm_mday = DD;
  tmSet.tm_hour = hh;
  tmSet.tm_min = mm;
  tmSet.tm_sec = ss;
  return mk_gmtime(&tmSet); 
}

void loop() {
  // put your main code here, to run repeatedly:
}

It returns 126393213 (Wed, 02 Jan 1974) which is weird, because I think, that I have set month and year shift right. I had wanted to use Arduino <Time.h> library but I didn’t, because I need set the time back by a 3 months for example. And I did’t find this function in the Time.h library. Thanks

http://www.nongnu.org/avr-libc/user-manual/group__avr__time.html#ga3346b04b0420b32ccf6b706551b70762

((126393213/86400)/365.24)+2000 = 2004.00526889

Looks about right.

Thank you, I thought that epoch is always seconds from 1970, but after adding 30 years it works :-)

From the documentation for that library:

Though not specified in the standard, it is often expected that time_t is a signed integer representing an offset in seconds from Midnight Jan 1 1970... i.e. 'Unix time'. This implementation uses an unsigned 32 bit integer offset from Midnight Jan 1 2000.