0

I've found a couple of posts about this but everybody always uses some libraries I'm just curious does anybody have any idea for how I can do this without using any libraries? Because I'm doing some exercise in this book and I built a date class that has members year month and day and now I have to change the class to basically be the days since epoch.

Seems a little hard though cuz like Jan has 31 days then feb(it says to exclude leap years) has 28 march has 31 and yeah it just seems a little hard to do this does anybody have any ideas?

yaelreshet11
  • 131
  • 5
  • 1
    Does this answer your question? [Math to convert seconds since 1970 into date and vice versa](https://stackoverflow.com/questions/7960318/math-to-convert-seconds-since-1970-into-date-and-vice-versa) – Passerby Nov 04 '21 at 09:58

1 Answers1

0

It's just an idea but, since you're doing days since epoch, you could first calculate years since 1970 and do that times 365 since you're not taking leap years into account. After that you just count how many days since the start of the year you used as input I guess.