blob: 101dd394d1c2e23df7c3249e058cae89990b52e0 [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
5#include "chrome/installer/util/google_update_experiment_util.h"
6
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]52927222013-03-19 22:38:1212#include "base/time.h"
[email protected]52927222013-03-19 22:38:1213
14namespace installer {
15
16namespace {
17
18const char* const kDays[] =
19 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
20
21const char* const kMonths[] =
22 { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
23 "Oct", "Nov", "Dec"};
24
25}
26
27string16 BuildExperimentDateString() {
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 = {};
39 base::Time::Now().UTCExplode(&then);
40 then.year += 1;
41 DCHECK(then.HasValidValues());
42
43 return UTF8ToUTF16(base::StringPrintf("%s, %02d %s %d %02d:%02d:%02d GMT",
44 kDays[then.day_of_week],
45 then.day_of_month,
46 kMonths[then.month - 1],
47 then.year,
48 then.hour,
49 then.minute,
50 then.second));
51}
52
53} // namespace installer
54