avr-libc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-commit] [2373] strftime 'D' conversion now restricted to 2 dig


From: Mike Rice
Subject: [avr-libc-commit] [2373] strftime 'D' conversion now restricted to 2 digits as per the spec.
Date: Mon, 29 Apr 2013 20:35:36 +0000

Revision: 2373
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2373
Author:   swfltek
Date:     2013-04-29 20:35:36 +0000 (Mon, 29 Apr 2013)
Log Message:
-----------
strftime 'D' conversion now restricted to 2 digits as per the spec.

Modified 'V' conversion to return final week number of previous year, rather 
than a canned '53', when the return from iso_weeknum == 0.

Modified Paths:
--------------
    trunk/avr-libc/libc/time/strftime.c

Modified: trunk/avr-libc/libc/time/strftime.c
===================================================================
--- trunk/avr-libc/libc/time/strftime.c 2013-04-29 15:56:07 UTC (rev 2372)
+++ trunk/avr-libc/libc/time/strftime.c 2013-04-29 20:35:36 UTC (rev 2373)
@@ -90,6 +90,7 @@
     int             d, w;
     char            c;
     char            _store[26];
+    struct tm       tm_temp;
 
     count = length = 0;
     while (count < limit) {
@@ -142,7 +143,7 @@
                 length = sprintf(_store, "%.2u/%.2u/%.2u", \
                          timeptr->tm_mon + 1, \
                          timeptr->tm_mday, \
-                         timeptr->tm_year \
+                         timeptr->tm_year % 100 \
                     );
                 break;
 
@@ -259,8 +260,15 @@
 
                        case ('V'):
                                w = iso_weeknum(timeptr);
-                               if (w == 0)
-                                       w = 53;
+                               if (w == 0){
+                                       /* we need the week number of the final 
week of the previous year */
+                                       tm_temp.tm_year = timeptr->tm_year - 1;
+                                       tm_temp.tm_mon = 11;
+                                       tm_temp.tm_mday = 11;
+                                       tm_temp.tm_hour = tm_temp.tm_min = 
tm_temp.tm_sec = 0;
+                                       mktime(&tm_temp);
+                                       w = iso_weeknum(&tm_temp);
+                               }
                                if (w == 54)
                                        w = 1;
                                length = sprintf(_store, "%.2u", w);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]