til_cli/learned.rs
1extern crate chrono;
2
3use chrono::prelude::*;
4
5#[derive(Debug)]
6pub struct Learned {
7 pub description: String,
8 pub date: Date<Local>,
9}
10
11impl Learned {
12 pub fn new(args: Vec<String>) -> Result<Learned, &'static str> {
13 if args.len() < 2 {
14 return Err("not enough arguments");
15 }
16
17 let description = args.clone().split_off(1).join(" ");
18
19 let date = Local::today();
20
21 Ok(Learned { description, date })
22 }
23}