Add XeRelease Rust Edition

This commit is contained in:
daleclack 2022-02-17 17:22:20 +08:00
parent 9e677284c5
commit 8e26c0f7b4
4 changed files with 133 additions and 9 deletions

View File

@ -0,0 +1,47 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'xerelease_rust'",
"cargo": {
"args": [
"build",
"--bin=xerelease_rust",
"--package=xerelease_rust",
"--release"
],
"filter": {
"name": "xerelease_rust",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'xerelease_rust'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=xerelease_rust",
"--package=xerelease_rust",
"--release"
],
"filter": {
"name": "xerelease_rust",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

View File

@ -2,13 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "XeRelease_Rust"
version = "0.1.0"
dependencies = [
"chrono",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -91,3 +84,10 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "xerelease_rust"
version = "0.1.0"
dependencies = [
"chrono",
]

View File

@ -1,5 +1,5 @@
[package]
name = "XeRelease_Rust"
name = "xerelease_rust"
version = "0.1.0"
edition = "2021"

View File

@ -1,5 +1,82 @@
use chrono::*;
use std::io;
fn main() {
println!("Hello, world!");
// Pointer to functions
let funcs = [about, longterm, stable, develop];
// Information
println!("Input Mode:");
println!("1.longterm;2.stable;3.develop");
// Input mode selection
let mut string = String::new();
io::stdin().read_line(&mut string).expect("Read Error!");
let index: usize = string.trim().parse().unwrap();
funcs[index]();
}
fn about() {
println!("XeRelease Rust Edition by daleclack");
}
fn longterm() {
// Get current time
let now = Utc::now();
let local = Local::now();
let naive_time = NaiveDate::from_ymd(2019, 1, 11).and_hms(0, 0, 0);
let other_dt = DateTime::<Utc>::from_utc(naive_time, Utc);
// Calculate the duration time
let diff = now.signed_duration_since(other_dt);
// Just print it on terminal
println!(
"5.4.{} {}-{}-{}",
diff.num_days(),
local.year(),
local.month(),
local.day()
);
}
fn stable() {
// Get current time
let now = Utc::now();
let local = Local::now();
let naive_time = NaiveDate::from_ymd(2017, 5, 19).and_hms(0, 0, 0);
let other_dt = DateTime::<Utc>::from_utc(naive_time, Utc);
// Calculate the duration time
let diff = now.signed_duration_since(other_dt);
// Just print it on terminal
println!(
"7.2.{} {}-{}-{}",
diff.num_days(),
local.year(),
local.month(),
local.day()
);
}
fn develop() {
// Get current time
let now = Utc::now();
let local = Local::now();
let naive_time = NaiveDate::from_ymd(2017, 5, 19).and_hms(0, 0, 0);
let other_dt = DateTime::<Utc>::from_utc(naive_time, Utc);
// Calculate the duration time
let diff = now.signed_duration_since(other_dt);
// Just print it on terminal
println!(
"8.0.{} {}-{}-{}",
diff.num_days(),
local.year(),
local.month(),
local.day()
);
}