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

Side by Side Diff: base/third_party/nspr/prtime.h

Issue 27339: Merge the latest version of PR_ParseTimeString.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Upload before checkin Created 11 years, 9 months 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
« no previous file with comments | « no previous file | base/third_party/nspr/prtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /* Portions are Copyright (C) 2007 Google Inc */
2 * Portions are Copyright (C) 2007 Google Inc 2 /* ***** BEGIN LICENSE BLOCK *****
3 * 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * ***** BEGIN LICENSE BLOCK ***** 4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 5 * The contents of this file are subject to the Mozilla Public License Version
6 * 6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * The contents of this file are subject to the Mozilla Public License Version 7 * the License. You may obtain a copy of the License at
8 * 1.1 (the "License"); you may not use this file except in compliance with 8 * http://www.mozilla.org/MPL/
9 * the License. You may obtain a copy of the License at 9 *
10 * http://www.mozilla.org/MPL/ 10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * Software distributed under the License is distributed on an "AS IS" basis, 12 * for the specific language governing rights and limitations under the
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 * License.
14 * for the specific language governing rights and limitations under the 14 *
15 * License. 15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 * 16 *
17 * The Original Code is the Netscape Portable Runtime (NSPR). 17 * The Initial Developer of the Original Code is
18 * 18 * Netscape Communications Corporation.
19 * The Initial Developer of the Original Code is 19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * Netscape Communications Corporation. 20 * the Initial Developer. All Rights Reserved.
21 * Portions created by the Initial Developer are Copyright (C) 1998-2000 21 *
22 * the Initial Developer. All Rights Reserved. 22 * Contributor(s):
23 * 23 *
24 * Contributor(s): 24 * Alternatively, the contents of this file may be used under the terms of
25 * 25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * Alternatively, the contents of this file may be used under the terms of 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * either the GNU General Public License Version 2 or later (the "GPL"), or 27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 * of those above. If you wish to allow use of your version of this file only
29 * in which case the provisions of the GPL or the LGPL are applicable instead 29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * of those above. If you wish to allow use of your version of this file only 30 * use your version of this file under the terms of the MPL, indicate your
31 * under the terms of either the GPL or the LGPL, and not to allow others to 31 * decision by deleting the provisions above and replace them with the notice
32 * use your version of this file under the terms of the MPL, indicate your 32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * decision by deleting the provisions above and replace them with the notice 33 * the provisions above, a recipient may use your version of this file under
34 * and other provisions required by the GPL or the LGPL. If you do not delete 34 * the terms of any one of the MPL, the GPL or the LGPL.
35 * the provisions above, a recipient may use your version of this file under 35 *
36 * the terms of any one of the MPL, the GPL or the LGPL. 36 * ***** END LICENSE BLOCK ***** */
37 *
38 * ***** END LICENSE BLOCK *****
39 */
40 37
41 /* 38 /*
42 *--------------------------------------------------------------------------- 39 *---------------------------------------------------------------------------
43 * 40 *
44 * prtime.h -- 41 * prtime.h --
45 * 42 *
46 * NSPR date and time functions 43 * NSPR date and time functions
47 * CVS revision 3.11 44 * CVS revision 3.10
48 * This file contains definitions of NSPR's basic types required by 45 * This file contains definitions of NSPR's basic types required by
49 * prtime.cc. These types have been copied over from the following NSPR 46 * prtime.cc. These types have been copied over from the following NSPR
50 * files prtime.h, prtypes.h(CVS revision 3.35), prlong.h(CVS revision 3.13) 47 * files prtime.h, prtypes.h(CVS revision 3.35), prlong.h(CVS revision 3.13)
51 * 48 *
52 *--------------------------------------------------------------------------- 49 *---------------------------------------------------------------------------
53 */ 50 */
54 51
55 #ifndef BASE_PRTIME_H__ 52 #ifndef BASE_PRTIME_H__
56 #define BASE_PRTIME_H__ 53 #define BASE_PRTIME_H__
57 54
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 count from 1900) */ 133 count from 1900) */
137 134
138 PRInt8 tm_wday; /* calculated day of the week 135 PRInt8 tm_wday; /* calculated day of the week
139 (0-6, Sun = 0) */ 136 (0-6, Sun = 0) */
140 PRInt16 tm_yday; /* calculated day of the year 137 PRInt16 tm_yday; /* calculated day of the year
141 (0-365, Jan 1 = 0) */ 138 (0-365, Jan 1 = 0) */
142 139
143 PRTimeParameters tm_params; /* time parameters used by conversion */ 140 PRTimeParameters tm_params; /* time parameters used by conversion */
144 } PRExplodedTime; 141 } PRExplodedTime;
145 142
143 /*
144 * PRTimeParamFn --
145 *
146 * A function of PRTimeParamFn type returns the time zone and
147 * daylight saving time corrections for some geographic location,
148 * given the current time in GMT. The input argument gmt should
149 * point to a PRExplodedTime that is in GMT, i.e., whose
150 * tm_params contains all 0's.
151 *
152 * For any time zone other than GMT, the computation is intended to
153 * consist of two steps:
154 * - Figure out the time zone correction, tp_gmt_offset. This number
155 * usually depends on the geographic location only. But it may
156 * also depend on the current time. For example, all of China
157 * is one time zone right now. But this situation may change
158 * in the future.
159 * - Figure out the daylight saving time correction, tp_dst_offset.
160 * This number depends on both the geographic location and the
161 * current time. Most of the DST rules are expressed in local
162 * current time. If so, one should apply the time zone correction
163 * to GMT before applying the DST rules.
164 */
165
166 typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt) ;
167
168 /**********************************************************************/
169 /****************************** FUNCTIONS *****************************/
170 /**********************************************************************/
171
146 NSPR_API(PRTime) 172 NSPR_API(PRTime)
147 PR_ImplodeTime(const PRExplodedTime *exploded); 173 PR_ImplodeTime(const PRExplodedTime *exploded);
148 174
149 /* 175 /*
176 * Adjust exploded time to normalize field overflows after manipulation.
177 * Note that the following fields of PRExplodedTime should not be
178 * manipulated:
179 * - tm_month and tm_year: because the number of days in a month and
180 * number of days in a year are not constant, it is ambiguous to
181 * manipulate the month and year fields, although one may be tempted
182 * to. For example, what does "a month from January 31st" mean?
183 * - tm_wday and tm_yday: these fields are calculated by NSPR. Users
184 * should treat them as "read-only".
185 */
186
187 NSPR_API(void) PR_NormalizeTime(
188 PRExplodedTime *exploded, PRTimeParamFn params);
189
190 /**********************************************************************/
191 /*********************** TIME PARAMETER FUNCTIONS *********************/
192 /**********************************************************************/
193
194 /* Time parameters that represent Greenwich Mean Time */
195 NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);
196
197 /*
150 * This parses a time/date string into a PRTime 198 * This parses a time/date string into a PRTime
151 * (microseconds after "1-Jan-1970 00:00:00 GMT"). 199 * (microseconds after "1-Jan-1970 00:00:00 GMT").
152 * It returns PR_SUCCESS on success, and PR_FAILURE 200 * It returns PR_SUCCESS on success, and PR_FAILURE
153 * if the time/date string can't be parsed. 201 * if the time/date string can't be parsed.
154 * 202 *
155 * Many formats are handled, including: 203 * Many formats are handled, including:
156 * 204 *
157 * 14 Apr 89 03:20:12 205 * 14 Apr 89 03:20:12
158 * 14 Apr 89 03:20 GMT 206 * 14 Apr 89 03:20 GMT
159 * Fri, 17 Mar 89 4:01:33 207 * Fri, 17 Mar 89 4:01:33
(...skipping 16 matching lines...) Expand all
176 * The correct value for this argument depends on what standard specified 224 * The correct value for this argument depends on what standard specified
177 * the time string which you are parsing. 225 * the time string which you are parsing.
178 */ 226 */
179 227
180 NSPR_API(PRStatus) PR_ParseTimeString ( 228 NSPR_API(PRStatus) PR_ParseTimeString (
181 const char *string, 229 const char *string,
182 PRBool default_to_gmt, 230 PRBool default_to_gmt,
183 PRTime *result); 231 PRTime *result);
184 232
185 #endif // BASE_PRTIME_H__ 233 #endif // BASE_PRTIME_H__
OLDNEW
« no previous file with comments | « no previous file | base/third_party/nspr/prtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698