/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2019 Danny Robson */ #pragma once #include "../expected.hpp" #include "../view.hpp" #include #include namespace cruft::parse::duration { /// Parse a number that represents a duration. eg, "1s", "5 minutes". /// /// The data view is updated to indicate the unused data. /// /// When there is no suffix it is assumed the quantity is in second. /// /// Note: The quantities are as defined by the standard std::chrono /// durations. This means that "1 month" will equal just under 30.5 days. /// Thus the utility is not universally useful for offsetting. expected consume (cruft::view &); /// Parse a number that represent a duration (as with `consume`). /// /// The operation will fail if the entire input is not consumed. expected from (cruft::view const&); }