mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
begin multi-protocol page driver implementation
This commit is contained in:
parent
5e2f9d6de0
commit
9d45688314
16 changed files with 796 additions and 830 deletions
24
src/tool.rs
24
src/tool.rs
|
|
@ -1,5 +1,8 @@
|
|||
//! Some shared helpers collection
|
||||
|
||||
// Global dependencies
|
||||
use gtk::glib::{DateTime, GString, Uri};
|
||||
|
||||
/// Format bytes to KB/MB/GB presentation
|
||||
pub fn format_bytes(value: usize) -> String {
|
||||
const KB: f32 = 1024.0;
|
||||
|
|
@ -21,3 +24,24 @@ pub fn format_bytes(value: usize) -> String {
|
|||
format!("{:.2} GB", f / GB)
|
||||
}
|
||||
}
|
||||
|
||||
/// Format given [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
|
||||
pub fn format_time(t: &DateTime) -> GString {
|
||||
t.format_iso8601().unwrap() // @TODO handle?
|
||||
}
|
||||
|
||||
/// Get current [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
|
||||
pub fn now() -> DateTime {
|
||||
DateTime::now_local().unwrap() // @TODO handle?
|
||||
}
|
||||
|
||||
/// Compare `subject` with `base`
|
||||
pub fn _is_external(subject: &Uri, base: &Uri) -> bool {
|
||||
if subject.scheme() != base.scheme() {
|
||||
return true;
|
||||
}
|
||||
if subject.port() != base.port() {
|
||||
return true;
|
||||
}
|
||||
subject.host() != base.host()
|
||||
} // @TODO not in use
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue