PageRenderTime 223ms CodeModel.GetById 100ms app.highlight 3ms RepoModel.GetById 118ms app.codeStats 0ms

/indra/newview/lldateutil.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 88 lines | 12 code | 11 blank | 65 comment | 0 complexity | 301f5321a783d14085dba58a732d00b1 MD5 | raw file
 1/** 
 2* @file lldateutil.h
 3*
 4* $LicenseInfo:firstyear=2009&license=viewerlgpl$
 5* Second Life Viewer Source Code
 6* Copyright (C) 2010, Linden Research, Inc.
 7* 
 8* This library is free software; you can redistribute it and/or
 9* modify it under the terms of the GNU Lesser General Public
10* License as published by the Free Software Foundation;
11* version 2.1 of the License only.
12* 
13* This library is distributed in the hope that it will be useful,
14* but WITHOUT ANY WARRANTY; without even the implied warranty of
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16* Lesser General Public License for more details.
17* 
18* You should have received a copy of the GNU Lesser General Public
19* License along with this library; if not, write to the Free Software
20* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21* 
22* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23* $/LicenseInfo$
24*/
25
26#ifndef LLDATEUTIL_H
27#define LLDATEUTIL_H
28
29class LLDate;
30
31namespace LLDateUtil
32{
33	/**
34	 * Convert a date provided by the server into seconds since the Epoch.
35	 * 
36	 * @param[out] date Number of seconds since 01/01/1970 UTC.
37	 * @param[in]  str  Date string (MM/DD/YYYY) in PDT time zone.
38	 * 
39	 * @return true on success, false on parse error
40	 */
41	bool dateFromPDTString(LLDate& date, const std::string& str);
42
43	/**
44	 * Get human-readable avatar age.
45	 * 
46	 * Used for avatar inspectors and profiles.
47	 * 
48	 * @param born_date Date an avatar was born on.
49	 * @param now       Current date.
50	 * 
51	 * @return human-readable localized string like "1 year, 2 months",
52	 *         or "???" on error.
53	 */
54	std::string ageFromDate(const LLDate& born_date, const LLDate& now);
55
56	// Convert a date provided by the server (MM/DD/YYYY) into a localized,
57	// human-readable age (1 year, 2 months) using translation strings.
58	// Pass LLDate::now() for now.
59	// Used for avatar inspectors and profiles.
60	std::string ageFromDate(const std::string& date_string, const LLDate& now);
61
62	// Calls the above with LLDate::now()
63	std::string ageFromDate(const std::string& date_string);
64
65	// As above, for YYYY-MM-DD dates
66	//std::string ageFromDateISO(const std::string& date_string, const LLDate& now);
67
68	// Calls the above with LLDate::now()
69	//std::string ageFromDateISO(const std::string& date_string);
70
71	//std::string ageFromDate(S32 born_year, S32 born_month, S32 born_day, const LLDate& now);
72
73	/**
74	 * Convert a string of a specified date format into seconds since the Epoch.
75	 *
76	 * Many of the format flags are those used by strftime(...), but not all.
77	 * For the full list of supported time format specifiers
78	 * see http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/date_time_io.html#date_time.format_flags
79	 *
80	 * @param format Format characters string. Example: "%A %b %d, %Y"
81	 * @param str    Date string containing the time in specified format.
82	 *
83	 * @return Number of seconds since 01/01/1970 UTC.
84	 */
85	S32 secondsSinceEpochFromString(const std::string& format, const std::string& str);
86}
87
88#endif