pub fn new(year: u16,
               month: u16,
               day: u16) -> Result<ScriptDate, ScriptDateError> {
        if month > 12 {
            Err(ScriptDateError::MonthTooLarge(month))
        } else if month == 0 {
            Err(ScriptDateError::MonthTooSmall(month))
        } else if day > 31 {
            Err(ScriptDateError::DayTooLarge(day))
        } else if day == 0 {
            Err(ScriptDateError::DayTooSmall(day))
        } else {
            Ok(ScriptDate {
                year: year,
                month: month,
                day: day,
            })
        }
    }
/// Creates a new `ScriptDate` from the given `year`, `month`, and `day`, if
/// possible.
///
/// If the month is greater than 12 or less than 1 or the day is greater
/// than 31 or less than 1, then an `Err` is returned with a value from the
/// `ScriptDateError` enum.
///
/// # Examples
///
/// Create a new valid `ScriptDate`:
///
/// ```rust
/// use iso15924::ScriptDate;
///
/// let _ = ScriptDate::new(2000, 1, 1).unwrap();
/// ```
///
/// As there can be errors, it's a good idea to match for the various
/// `ScriptDateError` values:
///
/// ```rust
/// use iso15924::{ScriptDateError, ScriptDate};
///
/// let month_too_small = ScriptDate::new(2000, 0, 1);
/// let month_too_large = ScriptDate::new(2000, 13, 1);
/// let day_too_small = ScriptDate::new(2000, 1, 0);
/// let day_too_large = ScriptDate::new(2000, 1, 35);
///
/// assert!(match month_too_small {
///     Err(ScriptDateError::MonthTooSmall(_)) => true,
///     _ => false,
/// });
/// assert!(match month_too_large {
///     Err(ScriptDateError::MonthTooLarge(_)) => true,
///     _ => false,
/// });
/// assert!(match day_too_small {
///     Err(ScriptDateError::DayTooSmall(_)) => true,
///     _ => false,
/// });
/// assert!(match day_too_large {
///     Err(ScriptDateError::DayTooLarge(_)) => true,
///     _ => false,
/// });
/// ```


If the month is greater than 12 or less than 1 or the day is greater
than 31 or less than 1, then an `Err` is returned with a value from the
`ScriptDateError` enum.
If the month is greater than 12 or less than 1 or the day is greater than 31 or less than 1 then an ` Err ` is returned with a value from the ` ScriptDateError ` enum .
pub fn new(year: u16,
               month: u16,
               day: u16) -> Result<ScriptDate, ScriptDateError> {
        if month > 12 {
            Err(ScriptDateError::MonthTooLarge(month))
        } else if month == 0 {
            Err(ScriptDateError::MonthTooSmall(month))
        } else if day > 31 {
            Err(ScriptDateError::DayTooLarge(day))
        } else if day == 0 {
            Err(ScriptDateError::DayTooSmall(day))
        } else {
            Ok(ScriptDate {
                year: year,
                month: month,
                day: day,
            })
        }
    }
pub fn new ( year : u16 , month : u16 , day : u16 ) -> Result < ScriptDate , ScriptDateError > { if month > 12 { Err ( ScriptDateError :: MonthTooLarge ( month ) ) } else if month == 0 { Err ( ScriptDateError :: MonthTooSmall ( month ) ) } else if day > 31 { Err ( ScriptDateError :: DayTooLarge ( day ) ) } else if day == 0 { Err ( ScriptDateError :: DayTooSmall ( day ) ) } else { Ok ( ScriptDate { year : year , month : month , day : day , } ) } }
Creates a new `ScriptDate` from the given `year`, `month`, and `day`, if
possible.
Creates a new ` ScriptDate ` from the given ` year ` ` month ` and ` day ` if possible .
year
u16
month
u16
day
u16
examples
Create a new valid `ScriptDate`.





As there can be errors, it's a good idea to match for the various
`ScriptDateError` values.

```rust
use iso15924::{ScriptDateError, ScriptDate}.



assert!(match month_too_small {
Err(ScriptDateError::MonthTooSmall(_)) => true,
_ => false,
});
assert!(match month_too_large {
Err(ScriptDateError::MonthTooLarge(_)) => true,
_ => false,
});
assert!(match day_too_small {
Err(ScriptDateError::DayTooSmall(_)) => true,
_ => false,
});
assert!(match day_too_large {
Err(ScriptDateError::DayTooLarge(_)) => true,
_ => false,
});
```
Create a new valid ` ScriptDate ` . As there can be errors it ' s a good idea to match for the various ` ScriptDateError ` values . ` ` ` rust use iso15924 :: { ScriptDateError ScriptDate } . assert! ( match month_too_small { Err ( ScriptDateError :: MonthTooSmall ( _ )) = > true _ = > false } ) ; assert! ( match month_too_large { Err ( ScriptDateError :: MonthTooLarge ( _ )) = > true _ = > false } ) ; assert! ( match day_too_small { Err ( ScriptDateError :: DayTooSmall ( _ )) = > true _ = > false } ) ; assert! ( match day_too_large { Err ( ScriptDateError :: DayTooLarge ( _ )) = > true _ = > false } ) ; ` ` `