summaryrefslogtreecommitdiff
path: root/chromium/components/ntp_snippets/time_serialization.cc
blob: a08074f11b965e3eb13a3c2311c4cf807ea39d34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/ntp_snippets/time_serialization.h"

namespace ntp_snippets {

int64_t SerializeTime(const base::Time& time) {
  return (time - base::Time()).InMicroseconds();
}

base::Time DeserializeTime(int64_t serialized_time) {
  return base::Time() + base::Microseconds(serialized_time);
}

}  // namespace ntp_snippets