blob: 50e81ffde6a30ad4c66507a6d019c6d588890bf0 [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]3164fa822013-06-28 15:32:4112#include "base/time/time.h"
[email protected]52927222013-03-19 22:38:1213
[email protected]d383ffc2013-12-06 15:27:2814namespace google_update {
15
16#if defined(OS_WIN)
17const wchar_t kExperimentLabels[] = L"experiment_labels";
18#endif
19
20const char kExperimentLabelSep[] = ";";
21
22} // namespace google_update
23
[email protected]52927222013-03-19 22:38:1224namespace installer {
25
26namespace {
27
28const char* const kDays[] =
29 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
30
31const char* const kMonths[] =
32 { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
33 "Oct", "Nov", "Dec"};
34
35}
36
[email protected]05aab99c2013-12-20 09:03:1537base::string16 BuildExperimentDateString(const base::Time& current_time) {
[email protected]52927222013-03-19 22:38:1238 // The Google Update experiment_labels timestamp format is:
39 // "DAY, DD0 MON YYYY HH0:MI0:SE0 TZ"
40 // DAY = 3 character day of week,
41 // DD0 = 2 digit day of month,
42 // MON = 3 character month of year,
43 // YYYY = 4 digit year,
44 // HH0 = 2 digit hour,
45 // MI0 = 2 digit minute,
46 // SE0 = 2 digit second,
47 // TZ = 3 character timezone
48 base::Time::Exploded then = {};
[email protected]21344672013-11-07 06:04:2849 current_time.UTCExplode(&then);
[email protected]52927222013-03-19 22:38:1250 then.year += 1;
51 DCHECK(then.HasValidValues());
52
53 return UTF8ToUTF16(base::StringPrintf("%s, %02d %s %d %02d:%02d:%02d GMT",
54 kDays[then.day_of_week],
55 then.day_of_month,
56 kMonths[then.month - 1],
57 then.year,
58 then.hour,
59 then.minute,
60 then.second));
61}
62
63} // namespace installer
64