Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: nspr/pr/src/misc/prtime.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public 2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 /* 6 /*
7 * prtime.c -- 7 * prtime.c --
8 * 8 *
9 * NSPR date and time functions 9 * NSPR date and time functions
10 * 10 *
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 *----------------------------------------------------------------------- 1665 *-----------------------------------------------------------------------
1666 * 1666 *
1667 * PR_FormatTime -- 1667 * PR_FormatTime --
1668 * 1668 *
1669 * Format a time value into a buffer. Same semantics as strftime(). 1669 * Format a time value into a buffer. Same semantics as strftime().
1670 * 1670 *
1671 *----------------------------------------------------------------------- 1671 *-----------------------------------------------------------------------
1672 */ 1672 */
1673 1673
1674 PR_IMPLEMENT(PRUint32) 1674 PR_IMPLEMENT(PRUint32)
1675 PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm) 1675 PR_FormatTime(char *buf, int buflen, const char *fmt,
1676 const PRExplodedTime *time)
1676 { 1677 {
1677 size_t rv; 1678 size_t rv;
1678 struct tm a; 1679 struct tm a;
1679 struct tm *ap; 1680 struct tm *ap;
1680 1681
1681 if (tm) { 1682 if (time) {
1682 ap = &a; 1683 ap = &a;
1683 a.tm_sec = tm->tm_sec; 1684 a.tm_sec = time->tm_sec;
1684 a.tm_min = tm->tm_min; 1685 a.tm_min = time->tm_min;
1685 a.tm_hour = tm->tm_hour; 1686 a.tm_hour = time->tm_hour;
1686 a.tm_mday = tm->tm_mday; 1687 a.tm_mday = time->tm_mday;
1687 a.tm_mon = tm->tm_month; 1688 a.tm_mon = time->tm_month;
1688 a.tm_wday = tm->tm_wday; 1689 a.tm_wday = time->tm_wday;
1689 a.tm_year = tm->tm_year - 1900; 1690 a.tm_year = time->tm_year - 1900;
1690 a.tm_yday = tm->tm_yday; 1691 a.tm_yday = time->tm_yday;
1691 a.tm_isdst = tm->tm_params.tp_dst_offset ? 1 : 0; 1692 a.tm_isdst = time->tm_params.tp_dst_offset ? 1 : 0;
1692 1693
1693 /* 1694 /*
1694 * On some platforms, for example SunOS 4, struct tm has two 1695 * On some platforms, for example SunOS 4, struct tm has two
1695 * additional fields: tm_zone and tm_gmtoff. 1696 * additional fields: tm_zone and tm_gmtoff.
1696 */ 1697 */
1697 1698
1698 #if (__GLIBC__ >= 2) || defined(XP_BEOS) \ 1699 #if (__GLIBC__ >= 2) || defined(XP_BEOS) \
1699 || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \ 1700 || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
1700 || defined(DARWIN) || defined(SYMBIAN) || defined(ANDROID) 1701 || defined(DARWIN) || defined(SYMBIAN) || defined(ANDROID)
1701 a.tm_zone = NULL; 1702 a.tm_zone = NULL;
1702 a.tm_gmtoff = tm->tm_params.tp_gmt_offset + 1703 a.tm_gmtoff = time->tm_params.tp_gmt_offset +
1703 tm->tm_params.tp_dst_offset; 1704 time->tm_params.tp_dst_offset;
1704 #endif 1705 #endif
1705 } else { 1706 } else {
1706 ap = NULL; 1707 ap = NULL;
1707 } 1708 }
1708 1709
1709 rv = strftime(buf, buflen, fmt, ap); 1710 rv = strftime(buf, buflen, fmt, ap);
1710 if (!rv && buf && buflen > 0) { 1711 if (!rv && buf && buflen > 0) {
1711 /* 1712 /*
1712 * When strftime fails, the contents of buf are indeterminate. 1713 * When strftime fails, the contents of buf are indeterminate.
1713 * Some callers don't check the return value from this function, 1714 * Some callers don't check the return value from this function,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if ther e 2003 /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if ther e
2003 * are any days left over ( dayOfYear % 7 ). Because we are only counting to 2004 * are any days left over ( dayOfYear % 7 ). Because we are only counting to
2004 * the first day of the week containing the given time, rather than to the 2005 * the first day of the week containing the given time, rather than to the
2005 * actual day representing the given time, any days in week 0 will be "abso rbed" 2006 * actual day representing the given time, any days in week 0 will be "abso rbed"
2006 * as extra days in the given week. 2007 * as extra days in the given week.
2007 */ 2008 */
2008 return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 ); 2009 return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 );
2009 } 2010 }
2010 } 2011 }
2011 2012
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698