todo_cli_manikya/lib.rs
1use chrono::{DateTime, Datelike, Local};
2
3/// Manage the status of the TUI application
4pub mod app;
5/// Manage the args passed in cli
6pub mod args;
7/// Manage tui event handling
8pub mod events;
9/// File management module for storing anf managing tasks
10pub mod files;
11/// The current state of tasks as a buffer in tui
12pub mod state;
13/// wrapper for all tui related functions
14pub mod tui;
15/// user interface for the tui
16pub mod ui;
17
18/// Generic wrapper for Result type
19///
20/// This will allow easy propagation of errors till the main function
21/// irrespectove of error type
22pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
23
24type Id = i32;
25
26pub fn get_id() -> Id {
27 fastrand::i32(1000..10000)
28}
29
30pub fn format_date(date: DateTime<Local>) -> String {
31 let now_date = Local::now();
32 // different years
33 if date.year() != now_date.year() {
34 format!("{}", date.format("%d/%m/%Y"))
35 } else {
36 format!("{}", date.format("%d/%m, %H:%M"))
37 }
38}