1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use libc::c_int;
use raw;
use util::Binding;
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Time {
raw: raw::git_time,
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct IndexTime {
raw: raw::git_index_time,
}
impl Time {
pub fn new(time: i64, offset: i32) -> Time {
unsafe {
Binding::from_raw(raw::git_time {
time: time as raw::git_time_t,
offset: offset as c_int,
})
}
}
pub fn seconds(&self) -> i64 { self.raw.time as i64 }
pub fn offset_minutes(&self) -> i32 { self.raw.offset as i32 }
}
impl Binding for Time {
type Raw = raw::git_time;
unsafe fn from_raw(raw: raw::git_time) -> Time {
Time { raw: raw }
}
fn raw(&self) -> raw::git_time { self.raw }
}
impl IndexTime {
pub fn new(seconds: i32, nanoseconds: u32) -> IndexTime {
unsafe {
Binding::from_raw(raw::git_index_time {
seconds: seconds,
nanoseconds: nanoseconds,
})
}
}
pub fn seconds(&self) -> i32 { self.raw.seconds }
pub fn nanoseconds(&self) -> u32 { self.raw.nanoseconds }
}
impl Binding for IndexTime {
type Raw = raw::git_index_time;
unsafe fn from_raw(raw: raw::git_index_time) -> IndexTime {
IndexTime { raw: raw }
}
fn raw(&self) -> raw::git_index_time { self.raw }
}