tigger:
Oh wow lads.
Please excuse my ignorance. All I'm asking is how to to use the b****y thing.
How do I turn a long time number into hours, mins etc.?
but hours, mins, etc... is not a time or a date
The unix epoch is midnight jan 1, 1970. The time_t value represents seconds since the epoch.
Knowing how many hours and mins since then is typically not very useful and it is actually not a simple calculation since there are leap years involved.
I'm guessing that hours and minutes, etc, is probably not what you are actually looking for.
Usually what is wanted is the human readable date and time components/elements such as month number, day of month number, hour of time, minute of time,etc...
And for that you use breakTime() it converts the time_t into its time elements (with no adjustment for timezone) and stores them the TimeElements structure you pass to it.
You can then you grab what you want from that structure as it has all those date and time element values in it.
Structures, pointers etc. mean not a lot to me. It's not Trump vs Kim il whatsit.
You will need to understand these to get very far as they are very basic concepts for the C/C++ language.
While you have not said specifically what you want, it sounds like you are wanting the date and time components represented by the epoch value.
Those values will be in the TimeElements data structure that you passed to breakTime() when it returns.
The definition of the TimeElements structure in the TimeLib.h header file.
You can see all the members.
You reference them through the data structure.
i.e.
tmName.Hour
tmName.Minute
tmName.Month
etc...
Just keep in mind that Year is relative to 1970 and not an actual year.
In terms of time zone support, while Jack's TimeZone library does work quite well, it is not the way timezones are normally handled on unix machines since normally there is a localtime() function that is timezone aware that handles it.
Since the Time library is not timeZone aware you must play games to offset the epoch value (which is actually changing the time) to trick the breakTime() code to providing the date & time elements for the local timezone.
Whenever tracking epoch time and using the Time library you must decide if you really need to track the REAL datetime of things or not.
The value of using the REAL time epoch is that no mater what timezone you are in the REAL time is always the same.
This can be valuable if you need a true time stamp.
But with this comes the issue of correcting for local time if the human ever wants to see the time based on the local timezone.
If on the other hand you don't need timezone independent timestamps, you can cheat and just pretend you are in london and not mess with timezones at all.
Yes the actual time represented by the epoch time_t value will be incorrect, but it doesn't matter since the local time displayed will still be correct.
So if localtime is all you need, it is simpler to ignore timezones.
--- bill