uClibc-0.9.28-new_dst_rules.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. --- uClibc/libc/misc/time/time.c (revision 16488)
  2. +++ uClibc/libc/misc/time/time.c (working copy)
  3. @@ -157,6 +157,22 @@
  4. #define TZNAME_MAX _POSIX_TZNAME_MAX
  5. #endif
  6. +#if defined (L_tzset) || defined (L_localtime_r) || defined(L_strftime) || \
  7. + defined(L__time_mktime) || defined(L__time_mktime_tzi) || \
  8. + ((defined(L_strftime) || defined(L_strftime_l)) && \
  9. + defined(__UCLIBC_HAS_XLOCALE__))
  10. +
  11. +void _time_tzset (int);
  12. +
  13. +#ifndef L__time_mktime
  14. +
  15. + /* Jan 1, 2007 Z - tm = 0,0,0,1,0,107,1,0,0 */
  16. +
  17. +const static time_t new_rule_starts = 1167609600;
  18. +
  19. +#endif
  20. +#endif
  21. +
  22. /**********************************************************************/
  23. /* The era code is currently unfinished. */
  24. /* #define ENABLE_ERA_CODE */
  25. @@ -532,7 +548,7 @@
  26. {
  27. __UCLIBC_MUTEX_LOCK(_time_tzlock);
  28. - tzset();
  29. + _time_tzset(*timer < new_rule_starts);
  30. __time_localtime_tzi(timer, result, _time_tzinfo);
  31. @@ -956,7 +972,8 @@
  32. unsigned char mod;
  33. unsigned char code;
  34. - tzset(); /* We'll, let's get this out of the way. */
  35. + /* We'll, let's get this out of the way. */
  36. + _time_tzset(_time_mktime((struct tm *) timeptr, 0) < new_rule_starts);
  37. lvl = 0;
  38. p = format;
  39. @@ -1644,7 +1661,9 @@
  40. 6, 0, 0, /* Note: overloaded for non-M non-J case... */
  41. 0, 1, 0, /* J */
  42. ',', 'M', '4', '.', '1', '.', '0',
  43. - ',', 'M', '1', '0', '.', '5', '.', '0', 0
  44. + ',', 'M', '1', '0', '.', '5', '.', '0', 0,
  45. + ',', 'M', '3', '.', '2', '.', '0',
  46. + ',', 'M', '1', '1', '.', '1', '.', '0', 0
  47. };
  48. #define TZ vals
  49. @@ -1652,6 +1671,7 @@
  50. #define RANGE (vals + 7)
  51. #define RULE (vals + 11 - 1)
  52. #define DEFAULT_RULES (vals + 22)
  53. +#define DEFAULT_2007_RULES (vals + 38)
  54. /* Initialize to UTC. */
  55. int daylight = 0;
  56. @@ -1774,6 +1794,11 @@
  57. void tzset(void)
  58. {
  59. + _time_tzset((time(NULL)) < new_rule_starts);
  60. +}
  61. +
  62. +void _time_tzset(int use_old_rules)
  63. +{
  64. register const char *e;
  65. register char *s;
  66. long off;
  67. @@ -1896,7 +1921,15 @@
  68. } else { /* OK, we have dst, so get some rules. */
  69. count = 0;
  70. if (!*e) { /* No rules so default to US rules. */
  71. - e = DEFAULT_RULES;
  72. + e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
  73. +#ifdef DEBUG_TZSET
  74. + if (e == DEFAULT_RULES)
  75. + printf("tzset: Using old rules.\n");
  76. + else if (e == DEFAULT_2007_RULES)
  77. + printf("tzset: Using new rules\n");
  78. + else
  79. + printf("tzset: Using undefined rules\n");
  80. +#endif /* DEBUG_TZSET */
  81. }
  82. do {
  83. @@ -2230,6 +2263,8 @@
  84. --d;
  85. }
  86. + _time_tzset (x.tm_year < 2007); /* tm_year was expanded above */
  87. +
  88. #ifdef __BCC__
  89. d = p[5] - 1;
  90. days = -719163L + ((long)d)*365 + ((d/4) - (d/100) + (d/400) + p[3] + p[7]);