[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 5 | #include "components/variations/variations_experiment_util.h" |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 6 | |
| 7 | #include <vector> |
| 8 | |
| 9 | #include "base/logging.h" |
[email protected] | 233a5f6 | 2013-06-11 06:22:09 | [diff] [blame] | 10 | #include "base/strings/stringprintf.h" |
[email protected] | 12bfb61 | 2013-06-07 19:54:02 | [diff] [blame] | 11 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 3164fa82 | 2013-06-28 15:32:41 | [diff] [blame] | 12 | #include "base/time/time.h" |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 13 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 14 | namespace variations { |
[email protected] | d383ffc | 2013-12-06 15:27:28 | [diff] [blame] | 15 | |
[email protected] | 056a1a4 | 2014-05-23 22:46:48 | [diff] [blame] | 16 | const base::char16 kExperimentLabelSeparator = ';'; |
[email protected] | d383ffc | 2013-12-06 15:27:28 | [diff] [blame] | 17 | |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 18 | namespace { |
| 19 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 20 | const char* const kDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 21 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 22 | const char* const kMonths[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
| 23 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 24 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 25 | } // namespace |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 26 | |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 27 | base::string16 BuildExperimentDateString(const base::Time& current_time) { |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 28 | // The Google Update experiment_labels timestamp format is: |
| 29 | // "DAY, DD0 MON YYYY HH0:MI0:SE0 TZ" |
| 30 | // DAY = 3 character day of week, |
| 31 | // DD0 = 2 digit day of month, |
| 32 | // MON = 3 character month of year, |
| 33 | // YYYY = 4 digit year, |
| 34 | // HH0 = 2 digit hour, |
| 35 | // MI0 = 2 digit minute, |
| 36 | // SE0 = 2 digit second, |
| 37 | // TZ = 3 character timezone |
| 38 | base::Time::Exploded then = {}; |
[email protected] | 2134467 | 2013-11-07 06:04:28 | [diff] [blame] | 39 | current_time.UTCExplode(&then); |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 40 | then.year += 1; |
| 41 | DCHECK(then.HasValidValues()); |
| 42 | |
[email protected] | c91b9d4 | 2013-12-25 00:53:42 | [diff] [blame] | 43 | return base::UTF8ToUTF16( |
| 44 | base::StringPrintf("%s, %02d %s %d %02d:%02d:%02d GMT", |
| 45 | kDays[then.day_of_week], |
| 46 | then.day_of_month, |
| 47 | kMonths[then.month - 1], |
| 48 | then.year, |
| 49 | then.hour, |
| 50 | then.minute, |
| 51 | then.second)); |
[email protected] | 5292722 | 2013-03-19 22:38:12 | [diff] [blame] | 52 | } |
| 53 | |
sdefresne | 1eeb90f | 2015-08-13 18:52:09 | [diff] [blame] | 54 | } // namespace variations |