chrono example types

This commit is contained in:
philippeitis
2022-10-07 21:46:03 -07:00
parent 158e52399e
commit 23dd5d7c24
3 changed files with 7 additions and 7 deletions

View File

@@ -65,7 +65,7 @@ words = [w.strip(',') for w in
def chrono_date():
return f"{CHRONO_DATE}::from_ymd({randint(1, 9999)}, {randint(1, 12)}, {randint(1, 31)})"
return f"chrono::NaiveDate::from_ymd({randint(1, 9999)}, {randint(1, 12)}, {randint(1, 31)})"
RUST_TYPE_RND_MAP = {
@@ -82,12 +82,12 @@ RUST_TYPE_RND_MAP = {
"Vec<u8>": lambda: f"vec![0, 1, 2, 3]",
"&Vec<u8>": lambda: f"&vec![0, 1, 2, 3]",
# TODO: styling this
f"{CHRONO_PATH}::Duration": lambda: f"{CHRONO_PATH}::Duration::seconds({randint(0, 9999999)})",
f"{CHRONO_PATH}::Duration": lambda: f"chrono::Duration::seconds({randint(0, 9999999)})",
CHRONO_DATE: chrono_date,
CHRONO_DATETIME: lambda: f"{CHRONO_PATH}::Utc::now()",
f"&{CHRONO_PATH}::Duration": lambda: f"&{CHRONO_PATH}::Duration::seconds({randint(0, 9999999)})",
CHRONO_DATETIME: lambda: f"chrono::Utc::now()",
f"&{CHRONO_PATH}::Duration": lambda: f"&chrono::Duration::seconds({randint(0, 9999999)})",
f"&{CHRONO_DATE}": lambda: f"&{chrono_date()}",
f"&{CHRONO_DATETIME}": lambda: f"&{CHRONO_PATH}::Utc::now()",
f"&{CHRONO_DATETIME}": lambda: f"&chrono::Utc::now()",
# why a reference to Vec? Because it works. Should be slice, but who knows how typing works here.
}
TREF = '$ref'

View File

@@ -44,7 +44,7 @@ ${lib.docs(c)}
pub use hyper;
pub use hyper_rustls;
pub extern crate google_apis_common as client;
pub use client::chrono;
pub mod api;
// Re-export the hub type and some basic client structs

View File

@@ -243,7 +243,7 @@ Arguments will always be copied or cloned into the builder, to make them indepen
###############################################################################################
<%def name="test_hub(hub_type, comments=True)">\
use std::default::Default;
use ${util.library_name()}::{${hub_type}, oauth2, hyper, hyper_rustls};
use ${util.library_name()}::{${hub_type}, oauth2, hyper, hyper_rustls, chrono};
% if comments:
// Get an ApplicationSecret instance by some means. It contains the `client_id` and