Struct glib::date::Date [] [src]

pub struct Date {
    // some fields omitted
}

Methods

impl Date

fn new() -> Option<Date>

Allocates a GDate and initializes it to a sane state. The new date will be cleared (as if you'd called g_date_clear()) but invalid (it won't represent an existing day).

fn new_dmy(day: Day, month: Month, year: Year) -> Option<Date>

Like g_date_new(), but also sets the value of the date. Assuming the day-month-year triplet you pass in represents an existing day, the returned date will be valid.

fn new_julian(julian_day: u32) -> Option<Date>

Like g_date_new(), but also sets the value of the date. Assuming the Julian day number you pass in is valid (greater than 0, less than an unreasonably large number), the returned date will be valid.

fn clear(&mut self)

Initializes one or more GDate structs to a sane but invalid state. The cleared dates will not represent an existing date, but will not contain garbage. Useful to init a date declared on the stack. Validity can be tested with g_date_valid().

fn set_day(&mut self, day: Day)

Sets the day of the month for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.

fn set_month(&mut self, month: Month)

Sets the month of the year for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.

fn set_year(&mut self, year: Year)

Sets the year for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.

fn set_dmy(&mut self, day: Day, month: Month, year: Year)

Sets the value of a GDate from a day, month, and year. The day-month-year triplet must be valid; if you aren't sure it is, call g_date_valid_dmy() to check before you set it.

fn set_julian(&mut self, julian: u32)

Sets the value of a GDate from a Julian day number.

fn set_time_t(&mut self, timet: i64)

Sets the value of a date to the date corresponding to a time specified as a time_t. The time to date conversion is done using the user's current timezone. To set the value of a date to the current day, you could write: Date::new().set_time_t(date, time::get_time().sec);

fn set_time_val(&mut self, timeval: &mut TimeVal)

Sets the value of a date from a GTimeVal value. Note that the tv_usec member is ignored, because GDate can't make use of the additional precision.

The time to date conversion is done using the user's current timezone.

fn set_parse(&mut self, str_: &str)

Parses a user-inputted string str , and try to figure out what date it represents, taking the current locale into account. If the string is successfully parsed, the date will be valid after the call. Otherwise, it will be invalid. You should check using g_date_valid() to see whether the parsing succeeded.

This function is not appropriate for file formats and the like; it isn't very precise, and its exact behavior varies with the locale. It's intended to be a heuristic routine that guesses what the user means by a given string (and it does work pretty well in that capacity).

fn add_days(&mut self, days: usize)

Increments a date some number of days. To move forward by weeks, add weeks*7 days. The date must be valid.

fn subtract_days(&mut self, days: usize)

Moves a date some number of days into the past. To move by weeks, just move by weeks*7 days. The date must be valid.

fn add_months(&mut self, months: usize)

Increments a date by some number of months. If the day of the month is greater than 28, this routine may change the day of the month (because the destination month may not have the current day in it). The date must be valid.

fn subtract_months(&mut self, months: usize)

Moves a date some number of months into the past. If the current day of the month doesn't exist in the destination month, the day of the month may change. The date must be valid.

fn add_years(&mut self, years: usize)

Increments a date by some number of years. If the date is February 29, and the destination year is not a leap year, the date will be changed to February 28. The date must be valid.

fn subtract_years(&mut self, years: usize)

Moves a date some number of years into the past. If the current day doesn't exist in the destination year (i.e. it's February 29 and you move to a non-leap-year) then the day is changed to February 29. The date must be valid.

fn days_between(&self, other: &Date) -> isize

Computes the number of days between two dates. If date2 is prior to date1 , the returned value is negative. Both dates must be valid.

fn compare(&self, other: &Date) -> isize

qsort()-style comparison function for dates. Both dates must be valid.

returned value : * 0 for equal * < 0 if lhs is less than rhs * > 0 if lhs is greater than rhs

fn clamp(&mut self, min_date: &Date, max_date: &Date)

If date is prior to min_date , sets date equal to min_date . If date falls after max_date , sets date equal to max_date . Otherwise, date is unchanged. Either of min_date and max_date may be NULL. All non-NULL dates must be valid.

fn order(&mut self, other: &mut Date)

Checks if date1 is less than or equal to date2 , and swap the values if this is not the case.

fn get_day(&self) -> Day

Returns the day of the month. The date must be valid.

fn get_month(&self) -> Month

Returns the month of the year. The date must be valid.

fn get_year(&self) -> Year

Returns the year of a GDate. The date must be valid.

fn get_julian(&self) -> u32

Returns the Julian day or "serial number" of the GDate. The Julian day is simply the number of days since January 1, Year 1; i.e., January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2, etc. The date must be valid.

fn get_weekday(&self) -> Weekday

Returns the day of the week for a GDate. The date must be valid.

fn get_day_of_year(&self) -> u32

Returns the day of the year, where Jan 1 is the first day of the year. The date must be valid.

fn is_first_of_month(&self) -> bool

Returns true if the date is on the first of a month. The date must be valid.

fn is_last_of_month(&self) -> bool

Returns true if the date is the last day of the month. The date must be valid.

fn get_monday_week_of_year(&self) -> u32

Returns the week of the year, where weeks are understood to start on Monday. If the date is before the first Monday of the year, return ???

The date must be valid.

fn get_sunday_week_of_year(&self) -> u32

Returns the week of the year during which this date falls, if weeks are understood to being on Sunday. The date must be valid. Can return 0 if the day is before the first Sunday of the year.

fn get_iso8601_week_of_year(&self) -> u32

Returns the week of the year, where weeks are interpreted according to ISO 8601.

fn is_valid(&self) -> bool

Returns TRUE if the GDate represents an existing day. The date must not contain garbage; it should have been initialized with g_date_clear() if it wasn't allocated by one of the g_date_new() variants.

Trait Implementations

impl Drop for Date

fn drop(&mut self)