use libc::{c_int, c_uint};
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: i64, nanoseconds: u32) -> IndexTime {
unsafe {
Binding::from_raw(raw::git_index_time {
seconds: seconds as raw::git_time_t,
nanoseconds: nanoseconds as c_uint,
})
}
}
pub fn seconds(&self) -> i64 { self.raw.seconds as i64 }
pub fn nanoseconds(&self) -> u32 { self.raw.nanoseconds as u32 }
}
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 }
}