1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::fs;
use std::error::Error;
use chrono::{Datelike, Timelike, Utc};
type Result<String> = ::std::result::Result<String, Box<dyn Error>>;
pub fn f_string<P: AsRef<str>>(s: P) -> Result<String> {
let r = fs::read_to_string(s.as_ref())?;
Ok(r)
}
pub fn get_file_date_name() -> String {
let mut r: String =String::new();
let now = Utc::now();
r.push_str(&now.year().to_string());
r.push_str(&now.month().to_string());
r.push_str(&now.day().to_string());
r
}
pub fn get_file_time_name() -> String {
let mut r= String::new();
let now = Utc::now();
let add_str = now.year().to_string()
+ &now.month().to_string()
+ &now.day().to_string()
+ &now.hour().to_string()
+ &now.minute().to_string();
r.push_str(&add_str);
r
}
pub fn v_f(v:Vec<String>) -> std::io::Result<()> {
let mut s=String::from("");
for i in v{
s.push_str(&i);
s.push('\n');
}
fs::write("./data/dup_rows", s)?;
Ok(())
}