summaryrefslogtreecommitdiffstats
path: root/media/mtp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-01-26 14:41:45 -0800
committerMike Lockwood <lockwood@android.com>2011-01-26 15:11:48 -0800
commit2107d23fc9d324ee3f5d5584c9a4bedb0fcf3da8 (patch)
tree659c9667ac963d07135da6e1e8e33b32ba60d551 /media/mtp
parent8fc7690f2b42c27f9f609647b96c17234aa9d78e (diff)
downloadframeworks_base-2107d23fc9d324ee3f5d5584c9a4bedb0fcf3da8.zip
frameworks_base-2107d23fc9d324ee3f5d5584c9a4bedb0fcf3da8.tar.gz
frameworks_base-2107d23fc9d324ee3f5d5584c9a4bedb0fcf3da8.tar.bz2
MTP: Fix month off by one error in date parsing and formatting code
BUG: 3379100 Change-Id: Ib386f0def9d611529ce0528b8159cef48df9cd85 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp')
-rw-r--r--media/mtp/MtpUtils.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/media/mtp/MtpUtils.cpp b/media/mtp/MtpUtils.cpp
index ab01ef5..6ec8876 100644
--- a/media/mtp/MtpUtils.cpp
+++ b/media/mtp/MtpUtils.cpp
@@ -55,7 +55,7 @@ bool parseDateTime(const char* dateTime, time_t& outSeconds) {
tm.tm_min = minute;
tm.tm_hour = hour;
tm.tm_mday = day;
- tm.tm_mon = month;
+ tm.tm_mon = month - 1; // mktime uses months in 0 - 11 range
tm.tm_year = year - 1900;
tm.tm_wday = 0;
tm.tm_isdst = -1;
@@ -72,7 +72,9 @@ void formatDateTime(time_t seconds, char* buffer, int bufferLength) {
localtime_r(&seconds, &tm);
snprintf(buffer, bufferLength, "%04d%02d%02dT%02d%02d%02d",
- tm.tm_year + 1900, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+ tm.tm_year + 1900,
+ tm.tm_mon + 1, // localtime_r uses months in 0 - 11 range
+ tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
}
} // namespace android