pub struct LocalClock;Expand description
Real wall-clock in the local timezone, matching Python’s datetime.now() (which is what
transformers uses for strftime_now). Requires the strftime feature.
SystemClock is UTC and dependency-free; this reads the local timezone offset via chrono
(the only thing we borrow from it — formatting still goes through our own strftime, so the
supported specifiers and their output are identical to the other clocks). Construct it and pass
it to ChatTemplateBuilder::clock when you need rendered
dates to match what transformers would emit on the same machine:
use hf_chat_template::{ChatTemplate, LocalClock};
let tmpl = ChatTemplate::builder("Today: {{ strftime_now('%Y') }}")
.clock(LocalClock)
.build()
.unwrap();Trait Implementations§
Source§impl Clock for LocalClock
Available on crate feature strftime only.
impl Clock for LocalClock
Available on crate feature
strftime only.Source§impl Clone for LocalClock
impl Clone for LocalClock
Source§fn clone(&self) -> LocalClock
fn clone(&self) -> LocalClock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for LocalClock
Source§impl Debug for LocalClock
impl Debug for LocalClock
Source§impl Default for LocalClock
impl Default for LocalClock
Source§fn default() -> LocalClock
fn default() -> LocalClock
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LocalClock
impl RefUnwindSafe for LocalClock
impl Send for LocalClock
impl Sync for LocalClock
impl Unpin for LocalClock
impl UnsafeUnpin for LocalClock
impl UnwindSafe for LocalClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more