Struct hgtime::HgTime

source ·
pub struct HgTime {
    pub unixtime: i64,
    pub offset: i32,
}
Expand description

A simple time structure that matches hg’s time representation.

Internally it’s unixtime (in GMT), and offset (GMT -1 = +3600).

Fields§

§unixtime: i64§offset: i32

Implementations§

Supported Range. This is to be compatible with Python stdlib.

The Python datetime library can only express a limited range of dates (0001-01-01 to 9999-12-31). Its strftime requires year >= 1900.

Return the current time with local timezone, or None if the timestamp is outside HgTime::RANGE.

The local timezone can be affected by set_default_offset.

Set as the faked “now”. Useful for testing.

This should only be used for testing.

Parse a date string.

Return None if it cannot be parsed.

This function matches mercurial.util.parsedate, and can parse some additional forms like 2 days ago.

Parse a date string as a range.

For example, Apr 2000 covers range Apr 1, 2000 to Apr 30, 2000. Also support more explicit ranges:

  • START to END
  • START

  • < END

See HgTime::RANGE for details.

See HgTime::RANGE for details.

Return None if timestamp is out of HgTime::RANGE.

Trait Implementations§

The resulting type after applying the + operator.
Performs the + operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.