Commit graph

6 commits

Author SHA1 Message Date
Michael Sevakis
248bff5eb8 Improve code for gmtime_r()
Unlike the current code, it does no looping to count days or do
table lookups, which means running time doesn't increase with year
or month. A good thing if it's call a lot, especially if the
algorithm were asked to compute dates centuries or more from the
epoch start.

As a bonus, handles negative time values.

Change-Id: I198a23daf621e40623e6b44dacf2387078b4db9c
2017-02-03 14:40:55 -05:00
Michael Sevakis
58b849c451 Move intrinsic RTC implmentation differences to driver files
Some drivers set tm_wday just fine and do not need it coerced to
be correct. Others set tm_yday, so don't overwrite what the driver
sets; just zero it inside if it can't fill the field. Move calls
to set_day_of_week() to the sorts of drivers that presumably
required the hammer (FS#11814) in get_time() where the weekday
isn't locked to the date.

Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
2017-01-26 23:07:49 -05:00
Rafaël Carré
24bd9d5393 gmtime: avoid a modulus
since WEEK_SECONDS = 7 * DAY_SECONDS, the result is the same

Change-Id: Iec161fc2de626c99c1aabf80ab1d3243eac602d9
2012-03-18 10:09:08 +01:00
Bertrik Sikken
16a95618de fix year calculation in gmtime
Change-Id: I9a5f29ad73b5620096d38874c70351db9bd90062
2012-03-12 08:50:10 +01:00
Rafaël Carré
d2aafd19e4 gmtime: reduce array size: days in month fit in 8 bits
Change-Id: Idcebdf0ae120cfc82a1f471d0553d23ca36d7eef
2012-03-11 17:19:48 -04:00
Bertrik Sikken
727e8aa681 Introduce gmtime.c and use it in the AS3514 RTC driver
Change-Id: I00a09ae28a68f8153fb8fa854fea741ddfb0bf09
Reviewed-on: http://gerrit.rockbox.org/175
Tested-by: Bertrik Sikken <bertrik@sikken.nl>
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Reviewed-by: Rafaël Carré <rafael.carre@gmail.com>
2012-03-11 22:10:54 +01:00