Merge pull request #542 from KodrAus/fix/timestamp-name

Rename to_timestamp to get_timestamp
This commit is contained in:
Ashley Mannix 2021-11-01 04:54:17 +10:00 committed by GitHub
commit b32f3728f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,7 +225,7 @@ impl Uuid {
/// value into more commonly-used formats, such as a unix timestamp. /// value into more commonly-used formats, such as a unix timestamp.
/// ///
/// [`Timestamp`]: v1/struct.Timestamp.html /// [`Timestamp`]: v1/struct.Timestamp.html
pub const fn to_timestamp(&self) -> Option<Timestamp> { pub const fn get_timestamp(&self) -> Option<Timestamp> {
match self.get_version() { match self.get_version() {
Some(Version::Mac) => { Some(Version::Mac) => {
let ticks: u64 = ((self.as_bytes()[6] & 0x0F) as u64) << 56 let ticks: u64 = ((self.as_bytes()[6] & 0x0F) as u64) << 56
@ -299,7 +299,7 @@ mod tests {
"20616934-4ba2-11e7-8000-010203040506" "20616934-4ba2-11e7-8000-010203040506"
); );
let ts = uuid.to_timestamp().unwrap().to_rfc4122(); let ts = uuid.get_timestamp().unwrap().to_rfc4122();
assert_eq!(ts.0 - 0x01B2_1DD2_1381_4000, 14_968_545_358_129_460); assert_eq!(ts.0 - 0x01B2_1DD2_1381_4000, 14_968_545_358_129_460);
assert_eq!(ts.1, 0); assert_eq!(ts.1, 0);
@ -315,7 +315,7 @@ mod tests {
uuid2.to_hyphenated().to_string(), uuid2.to_hyphenated().to_string(),
"20616934-4ba2-11e7-8001-010203040506" "20616934-4ba2-11e7-8001-010203040506"
); );
assert_eq!(uuid2.to_timestamp().unwrap().to_rfc4122().1, 1) assert_eq!(uuid2.get_timestamp().unwrap().to_rfc4122().1, 1)
}; };
} }
} }