Date and Time with ard/dates
The ard/dates module provides functions for working with date and time information.
The dates module provides:
- Current date retrieval to get today’s date as a string
use ard/datesuse ard/io
fn main() { let today = dates::get_today() io::print("Today is: {today}")}fn get_today() Str
Section titled “fn get_today() Str”Get today’s date as a string in standard date format.
use ard/dates
let date_str = dates::get_today()Examples
Section titled “Examples”Display Current Date
Section titled “Display Current Date”use ard/datesuse ard/io
fn main() { let today = dates::get_today() io::print(today)}Log with Current Date
Section titled “Log with Current Date”use ard/datesuse ard/iouse ard/fs
fn main() { let timestamp = dates::get_today() let message = "{timestamp}: Application started" fs::append("app.log", "{message}\n").expect("Failed to write log")}