sapling/eden/fs/utils/ChronoUnit.h
Andres Suarez fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00

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