PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LLDATEUTIL_H
  26. #define LLDATEUTIL_H
  27. class LLDate;
  28. namespace LLDateUtil
  29. {
  30. /**
  31. * Convert a date provided by the server into seconds since the Epoch.
  32. *
  33. * @param[out] date Number of seconds since 01/01/1970 UTC.
  34. * @param[in] str Date string (MM/DD/YYYY) in PDT time zone.
  35. *
  36. * @return true on success, false on parse error
  37. */
  38. bool dateFromPDTString(LLDate& date, const std::string& str);
  39. /**
  40. * Get human-readable avatar age.
  41. *
  42. * Used for avatar inspectors and profiles.
  43. *
  44. * @param born_date Date an avatar was born on.
  45. * @param now Current date.
  46. *
  47. * @return human-readable localized string like "1 year, 2 months",
  48. * or "???" on error.
  49. */
  50. std::string ageFromDate(const LLDate& born_date, const LLDate& now);
  51. // Convert a date provided by the server (MM/DD/YYYY) into a localized,
  52. // human-readable age (1 year, 2 months) using translation strings.
  53. // Pass LLDate::now() for now.
  54. // Used for avatar inspectors and profiles.
  55. std::string ageFromDate(const std::string& date_string, const LLDate& now);
  56. // Calls the above with LLDate::now()
  57. std::string ageFromDate(const std::string& date_string);
  58. // As above, for YYYY-MM-DD dates
  59. //std::string ageFromDateISO(const std::string& date_string, const LLDate& now);
  60. // Calls the above with LLDate::now()
  61. //std::string ageFromDateISO(const std::string& date_string);
  62. //std::string ageFromDate(S32 born_year, S32 born_month, S32 born_day, const LLDate& now);
  63. /**
  64. * Convert a string of a specified date format into seconds since the Epoch.
  65. *
  66. * Many of the format flags are those used by strftime(...), but not all.
  67. * For the full list of supported time format specifiers
  68. * see http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/date_time_io.html#date_time.format_flags
  69. *
  70. * @param format Format characters string. Example: "%A %b %d, %Y"
  71. * @param str Date string containing the time in specified format.
  72. *
  73. * @return Number of seconds since 01/01/1970 UTC.
  74. */
  75. S32 secondsSinceEpochFromString(const std::string& format, const std::string& str);
  76. }
  77. #endif