pub struct Cal;Expand description
Scheme for formats that have only calendar specifiers, such as <YYYY>.<MM>.<DD>.
This scheme is less useful than CalSem because there is no way to increment it twice in the
same period of its least significant specifier. For example, a version with format
<YYYY>.<MM>.<DD> can only be incremented/updated once per day.
See the available specifiers for this scheme in the table.
§Rules
- The first specifier must be a year (
YYYY,YY, or0Y). - For adjacent specifiers
aandb,bmust be relative toa:- month specifiers are relative to year ones (e.g.,
<YYYY>.<MM>) - day specifiers are relative to month ones (e.g.,
<YYYY>.<MM>.<DD>) - week specifiers are relative to year ones (and not month ones) (e.g.,
<YYYY>.<WW>)
- month specifiers are relative to year ones (e.g.,
- As for all schemes, arbitrary literals can be placed in the format string. For example, dots,
hyphens, or any other character(s) can be used, such as
y<YYYY>m<MM>d<DD>.
§Example Formats
<YYYY>.<0M>.<0D>: Full year, zero-padded month, and zero-padded day. Dot-separated.<0Y>.<0M>.<0D>: Zero-padded year, zero-padded month, and zero-padded day. Dot-separated.<YYYY>-<0W>: Full year and zero-padded week. Hyphen-separated.
Implementations§
Source§impl Cal
impl Cal
Sourcepub fn next_version_string(
format_str: &str,
version_str: &str,
date: Date,
) -> Result<String, CompositeError>
pub fn next_version_string( format_str: &str, version_str: &str, date: Date, ) -> Result<String, CompositeError>
Increments the version string (formatted by the format string) by the given date and returns the new version’s string.
This is a convenience method that creates a temporary Format and Version with
Scheme::new_version, and increments it with
Version::next.
§Example
use nextver::prelude::*;
let date = Date::utc_now(); // assume today is 2024-02-23
let next_str = Cal::next_version_string(
"<YYYY>.<0M>.<0D>",
"2001.02.03",
date
).unwrap();
assert_eq!("2024.02.23", next_str);§Errors
Returns a CompositeError of all error surface area from Self::new_version and
Version::next.
Trait Implementations§
Source§impl Scheme for Cal
impl Scheme for Cal
Source§fn new_format(format_str: &str) -> Result<Format<'_, Self>, FormatError>
fn new_format(format_str: &str) -> Result<Format<'_, Self>, FormatError>
Source§fn new_version<'vs>(
format_str: &str,
version_str: &'vs str,
) -> Result<Version<'vs, Self>, CompositeError>
fn new_version<'vs>( format_str: &str, version_str: &'vs str, ) -> Result<Version<'vs, Self>, CompositeError>
impl Eq for Cal
impl StructuralPartialEq for Cal
Auto Trait Implementations§
impl Freeze for Cal
impl RefUnwindSafe for Cal
impl Send for Cal
impl Sync for Cal
impl Unpin for Cal
impl UnwindSafe for Cal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more