blob: 9cf78bbabc0159e0d7088c92d42d05038b81e5fe [file] [log] [blame]
[email protected]52927222013-03-19 22:38:121// 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
sdefresne1eeb90f2015-08-13 18:52:095#include "components/variations/variations_experiment_util.h"
[email protected]52927222013-03-19 22:38:126
7#include <vector>
8
9#include "base/logging.h"
[email protected]233a5f62013-06-11 06:22:0910#include "base/strings/stringprintf.h"
[email protected]12bfb612013-06-07 19:54:0211#include "base/strings/utf_string_conversions.h"
[email protected]3164fa822013-06-28 15:32:4112#include "base/time/time.h"
[email protected]52927222013-03-19 22:38:1213
sdefresne1eeb90f2015-08-13 18:52:0914namespace variations {
[email protected]d383ffc2013-12-06 15:27:2815
[email protected]056a1a42014-05-23 22:46:4816const base::char16 kExperimentLabelSeparator = ';';
[email protected]d383ffc2013-12-06 15:27:2817
[email protected]52927222013-03-19 22:38:1218namespace {
19
sdefresne1eeb90f2015-08-13 18:52:0920const char* const kDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
[email protected]52927222013-03-19 22:38:1221
sdefresne1eeb90f2015-08-13 18:52:0922const char* const kMonths[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
23 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
[email protected]52927222013-03-19 22:38:1224
sdefresne1eeb90f2015-08-13 18:52:0925} // namespace
[email protected]52927222013-03-19 22:38:1226
[email protected]05aab99c2013-12-20 09:03:1527base::string16 BuildExperimentDateString(const base::Time& current_time) {
[email protected]52927222013-03-19 22:38:1228 // 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]21344672013-11-07 06:04:2839 current_time.UTCExplode(&then);
[email protected]52927222013-03-19 22:38:1240 then.year += 1;
41 DCHECK(then.HasValidValues());
42
[email protected]c91b9d42013-12-25 00:53:4243 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]52927222013-03-19 22:38:1252}
53
sdefresne1eeb90f2015-08-13 18:52:0954} // namespace variations