mirror of https://github.com/vinc/moros.git
Run geodate in userspace
This commit is contained in:
parent
5a7798aba1
commit
6ad0649281
Binary file not shown.
|
@ -0,0 +1,29 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use geodate::geodate;
|
||||
use moros::entry_point;
|
||||
use moros::api::clock;
|
||||
use moros::api::syscall;
|
||||
|
||||
entry_point!(main);
|
||||
|
||||
fn main(args: &[&str]) {
|
||||
if args.len() < 2 {
|
||||
syscall::write(1, b"Usage: geodate <longitude> [<timestamp>]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
let format = "%h:%y:%m:%d:%c:%b";
|
||||
let longitude = args[1].parse().expect("Could not parse longitude");
|
||||
let timestamp = if args.len() == 3 {
|
||||
args[2].parse().expect("Could not parse timestamp")
|
||||
} else {
|
||||
clock::realtime()
|
||||
};
|
||||
|
||||
let t = geodate::get_formatted_date(format, timestamp as i64, longitude);
|
||||
syscall::write(1, t.as_bytes());
|
||||
}
|
|
@ -25,6 +25,7 @@ pub fn copy_files(verbose: bool) {
|
|||
copy_file("/bin/halt", include_bytes!("../../dsk/bin/halt"), verbose);
|
||||
//copy_file("/bin/hello", include_bytes!("../../dsk/bin/hello"), verbose);
|
||||
copy_file("/bin/print", include_bytes!("../../dsk/bin/print"), verbose);
|
||||
copy_file("/bin/geodate", include_bytes!("../../dsk/bin/geodate"), verbose);
|
||||
copy_file("/bin/reboot", include_bytes!("../../dsk/bin/reboot"), verbose);
|
||||
copy_file("/bin/sleep", include_bytes!("../../dsk/bin/sleep"), verbose);
|
||||
|
||||
|
|
|
@ -457,7 +457,7 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
|
|||
"elf" => usr::elf::main(&args),
|
||||
"env" => usr::env::main(&args),
|
||||
"find" => usr::find::main(&args),
|
||||
"geodate" => usr::geodate::main(&args),
|
||||
//"geodate" => usr::geodate::main(&args),
|
||||
"goto" => cmd_change_dir(&args, config), // TODO: Remove this
|
||||
"hash" => usr::hash::main(&args),
|
||||
"help" => usr::help::main(&args),
|
||||
|
|
Loading…
Reference in New Issue