Skip to content

Commit 13799e2

Browse files
committed
feat: Time::new(seconds_since_epoch, offset) (#364)
1 parent 59d75fc commit 13799e2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

git-actor/src/time.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ impl Default for Time {
2323
}
2424

2525
impl Time {
26+
/// Create a new instance from seconds and offset.
27+
pub fn new(seconds_since_unix_epoch: u32, offset_in_seconds: i32) -> Self {
28+
Time {
29+
seconds_since_unix_epoch,
30+
offset_in_seconds,
31+
sign: offset_in_seconds.into(),
32+
}
33+
}
34+
2635
/// Serialize this instance to `out` in a format suitable for use in header fields of serialized git commits or tags.
2736
pub fn write_to(&self, mut out: impl io::Write) -> io::Result<()> {
2837
let mut itoa = itoa::Buffer::new();

0 commit comments

Comments
 (0)