feat: complete M3 runtime snapshot and profile save archive
This commit is contained in:
@@ -65,6 +65,11 @@ pub fn format_timestamp_micros(micros: i64) -> String {
|
||||
format!("{seconds}.{subsec_micros:06}Z")
|
||||
}
|
||||
|
||||
/// 统一把 `OffsetDateTime` 转成 Unix 微秒时间戳,避免各模块重复手写纳秒除法。
|
||||
pub fn offset_datetime_to_unix_micros(value: OffsetDateTime) -> i64 {
|
||||
(value.unix_timestamp_nanos() / 1_000) as i64
|
||||
}
|
||||
|
||||
/// 统一格式化 RFC3339 字符串,避免每个模块自己拼格式化错误文案。
|
||||
pub fn format_rfc3339(value: OffsetDateTime) -> Result<String, String> {
|
||||
value
|
||||
@@ -127,6 +132,15 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offset_datetime_to_unix_micros_is_stable() {
|
||||
let value = OffsetDateTime::UNIX_EPOCH
|
||||
+ time::Duration::seconds(1_713_686_401)
|
||||
+ time::Duration::microseconds(234_567);
|
||||
|
||||
assert_eq!(offset_datetime_to_unix_micros(value), 1_713_686_401_234_567);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_and_parse_rfc3339_round_trip() {
|
||||
let now = OffsetDateTime::UNIX_EPOCH + time::Duration::seconds(1_713_686_400);
|
||||
|
||||
Reference in New Issue
Block a user