pub struct Date {
pub year: i32,
pub month: u8,
pub day: u8,
}Expand description
A calendar day.
Fields§
§year: i32The year.
month: u81 to 12.
day: u8Day of the month, from 1.
Implementations§
Source§impl Date
impl Date
Sourcepub const fn new(year: i32, month: u8, day: u8) -> Self
pub const fn new(year: i32, month: u8, day: u8) -> Self
A date from year, month (1 to 12) and day (from 1).
Sourcepub fn days(self) -> i64
pub fn days(self) -> i64
Days since 1970-01-01; negative before it.
Examples found in repository?
examples/gallery.rs (line 1293)
1248pub fn app() -> App {
1249 App {
1250 name: "Gallery".into(),
1251 presses: 0,
1252 page: 0,
1253 room: 0,
1254 filter: String::new(),
1255 notes: String::new(),
1256 renaming: None,
1257 light: false,
1258 contrast: false,
1259 system: false,
1260 spacing: 1,
1261 ticked: false,
1262 on: true,
1263 folded_open: true,
1264 second: false,
1265 level: 72.0,
1266 bold: false,
1267 starred: true,
1268 span: 1,
1269 busy: false,
1270 from: 20.0,
1271 to: 70.0,
1272 followed: 0,
1273 finding: false,
1274 colour: 6,
1275 wanted: String::new(),
1276 picture: None,
1277 photo: None,
1278 drawings: None,
1279 animation: None,
1280 playing: false,
1281 // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282 letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283 place: String::new(),
1284 shape: None,
1285 selected_row: 1,
1286 tree_open: [true, true],
1287 amount: 4.0,
1288 off: true,
1289 count: 12,
1290 day: Date::today(),
1291 alarm: Time::new(7, 30, 0),
1292 meeting: (Date::today(), Time::new(14, 0, 0)),
1293 away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294 marked: 3.0,
1295 zoom: 100.0,
1296 within: 2.5,
1297 fruit: "pear",
1298 faint: true,
1299 hide: false,
1300 tint: Theme::dark().accent,
1301 drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302 table: Table { frozen: 1, ..Default::default() },
1303 selection: Selection::default(),
1304 files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305 tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306 code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307 lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308 inspector: Inspector::default(),
1309 beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310 file_dialog: FileDialog::default(),
1311 dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312 step: 2,
1313 results: 0,
1314 query: String::new(),
1315 topics: vec!["mountains".into(), "walks".into()],
1316 topic: String::new(),
1317 stars: 3.5,
1318 face: None,
1319 liked: [true, false],
1320 loading: true,
1321 banner: true,
1322 styles: [true, false, false],
1323 section: Some(0),
1324 slices: ChartView::default(),
1325 view: ChartView::default(),
1326 dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327 live: false,
1328 load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329 fed: taut::platform::unix_time(),
1330 folders: TreeView::default(),
1331 writing: Markdown::parse(WRITING),
1332 }
1333}Sourcepub fn from_days(days: i64) -> Self
pub fn from_days(days: i64) -> Self
The date days after 1970-01-01. Beyond the representable years, the first or last.
Examples found in repository?
More examples
examples/gallery.rs (line 1293)
1248pub fn app() -> App {
1249 App {
1250 name: "Gallery".into(),
1251 presses: 0,
1252 page: 0,
1253 room: 0,
1254 filter: String::new(),
1255 notes: String::new(),
1256 renaming: None,
1257 light: false,
1258 contrast: false,
1259 system: false,
1260 spacing: 1,
1261 ticked: false,
1262 on: true,
1263 folded_open: true,
1264 second: false,
1265 level: 72.0,
1266 bold: false,
1267 starred: true,
1268 span: 1,
1269 busy: false,
1270 from: 20.0,
1271 to: 70.0,
1272 followed: 0,
1273 finding: false,
1274 colour: 6,
1275 wanted: String::new(),
1276 picture: None,
1277 photo: None,
1278 drawings: None,
1279 animation: None,
1280 playing: false,
1281 // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282 letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283 place: String::new(),
1284 shape: None,
1285 selected_row: 1,
1286 tree_open: [true, true],
1287 amount: 4.0,
1288 off: true,
1289 count: 12,
1290 day: Date::today(),
1291 alarm: Time::new(7, 30, 0),
1292 meeting: (Date::today(), Time::new(14, 0, 0)),
1293 away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294 marked: 3.0,
1295 zoom: 100.0,
1296 within: 2.5,
1297 fruit: "pear",
1298 faint: true,
1299 hide: false,
1300 tint: Theme::dark().accent,
1301 drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302 table: Table { frozen: 1, ..Default::default() },
1303 selection: Selection::default(),
1304 files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305 tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306 code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307 lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308 inspector: Inspector::default(),
1309 beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310 file_dialog: FileDialog::default(),
1311 dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312 step: 2,
1313 results: 0,
1314 query: String::new(),
1315 topics: vec!["mountains".into(), "walks".into()],
1316 topic: String::new(),
1317 stars: 3.5,
1318 face: None,
1319 liked: [true, false],
1320 loading: true,
1321 banner: true,
1322 styles: [true, false, false],
1323 section: Some(0),
1324 slices: ChartView::default(),
1325 view: ChartView::default(),
1326 dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327 live: false,
1328 load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329 fed: taut::platform::unix_time(),
1330 folders: TreeView::default(),
1331 writing: Markdown::parse(WRITING),
1332 }
1333}Sourcepub fn month_length(self) -> u8
pub fn month_length(self) -> u8
Days in its month.
Sourcepub fn add_months(self, months: i32) -> Self
pub fn add_months(self, months: i32) -> Self
The same day months later (earlier, if negative); the month’s last day if it has
fewer.
Sourcepub fn today() -> Self
pub fn today() -> Self
Today, in local time.
Examples found in repository?
examples/gallery.rs (line 1290)
1248pub fn app() -> App {
1249 App {
1250 name: "Gallery".into(),
1251 presses: 0,
1252 page: 0,
1253 room: 0,
1254 filter: String::new(),
1255 notes: String::new(),
1256 renaming: None,
1257 light: false,
1258 contrast: false,
1259 system: false,
1260 spacing: 1,
1261 ticked: false,
1262 on: true,
1263 folded_open: true,
1264 second: false,
1265 level: 72.0,
1266 bold: false,
1267 starred: true,
1268 span: 1,
1269 busy: false,
1270 from: 20.0,
1271 to: 70.0,
1272 followed: 0,
1273 finding: false,
1274 colour: 6,
1275 wanted: String::new(),
1276 picture: None,
1277 photo: None,
1278 drawings: None,
1279 animation: None,
1280 playing: false,
1281 // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282 letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283 place: String::new(),
1284 shape: None,
1285 selected_row: 1,
1286 tree_open: [true, true],
1287 amount: 4.0,
1288 off: true,
1289 count: 12,
1290 day: Date::today(),
1291 alarm: Time::new(7, 30, 0),
1292 meeting: (Date::today(), Time::new(14, 0, 0)),
1293 away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294 marked: 3.0,
1295 zoom: 100.0,
1296 within: 2.5,
1297 fruit: "pear",
1298 faint: true,
1299 hide: false,
1300 tint: Theme::dark().accent,
1301 drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302 table: Table { frozen: 1, ..Default::default() },
1303 selection: Selection::default(),
1304 files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305 tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306 code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307 lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308 inspector: Inspector::default(),
1309 beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310 file_dialog: FileDialog::default(),
1311 dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312 step: 2,
1313 results: 0,
1314 query: String::new(),
1315 topics: vec!["mountains".into(), "walks".into()],
1316 topic: String::new(),
1317 stars: 3.5,
1318 face: None,
1319 liked: [true, false],
1320 loading: true,
1321 banner: true,
1322 styles: [true, false, false],
1323 section: Some(0),
1324 slices: ChartView::default(),
1325 view: ChartView::default(),
1326 dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327 live: false,
1328 load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329 fed: taut::platform::unix_time(),
1330 folders: TreeView::default(),
1331 writing: Markdown::parse(WRITING),
1332 }
1333}Trait Implementations§
impl Copy for Date
Source§impl Display for Date
ISO 8601, which sorts: 2026-11-30. For the user’s format, see
ui.format_date(date).
impl Display for Date
ISO 8601, which sorts: 2026-11-30. For the user’s format, see
ui.format_date(date).
impl Eq for Date
Source§impl Inspect for Date
impl Inspect for Date
Source§fn part(&mut self, row: &mut InspectorRow<'_>) -> Response
fn part(&mut self, row: &mut InspectorRow<'_>) -> Response
For a single-row value: its editor, described beside the name;
changed is set when the
user edits it. For a heading: what shows beside its name (a list shows its length).Source§fn hashed(&self) -> u64
fn hashed(&self) -> u64
A hash of the value: different values give different hashes. With several values
inspected it shows where they differ; compared with the initial state, what was edited.
(A struct’s is 0: its rows are compared one by one.)
Source§fn fields(&mut self, fields: &mut Fields<'_>)
fn fields(&mut self, fields: &mut Fields<'_>)
For a heading: lists its children, each with
fields.field(..), in display order.Source§fn mixed(&mut self, row: &mut InspectorRow<'_>) -> Response
fn mixed(&mut self, row: &mut InspectorRow<'_>) -> Response
The same where the inspected values differ: an editor showing that they do; when edited
(
changed), every value is set as the first then is. By default, a “—” box that does
that when pressed.Source§impl Ord for Date
impl Ord for Date
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Date
impl PartialOrd for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Forget for Date
impl Freeze for Date
impl Move for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnsafeUnpin for Date
impl UnwindSafe for Date
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more