mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
45 lines
993 B
C++
45 lines
993 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <folly/CppAttributes.h>
|
|
#include <folly/Range.h>
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
/**
|
|
* A structure representing information about a duration unit.
|
|
*/
|
|
struct ChronoUnit {
|
|
folly::StringPiece name;
|
|
intmax_t num;
|
|
intmax_t den;
|
|
};
|
|
|
|
/**
|
|
* Parse a string as a time duration unit.
|
|
*
|
|
* This is used to help parse time strings like "1m30s"
|
|
* Given the unit portion of this string (e.g., "m", "ns") this returns a
|
|
* pointer to an appropriate ChronoUnit, or nullptr if the string does not
|
|
* correspond to a valid unit name.
|
|
*
|
|
* e.g.,
|
|
* ns --> num=1, den=1000000000
|
|
* ms --> num=1, den=1000
|
|
* day --> num=86400, den=1
|
|
*/
|
|
const ChronoUnit* FOLLY_NULLABLE
|
|
lookupChronoUnitInfo(folly::StringPiece unitName);
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|