pub struct LocalTime { /* private fields */ }Expand description
Shows a <time> in the browser locale and time zone.
The server writes UTC text. The browser replaces it with local text. If
the element has no title, the runtime copies the server text to
title. The locale is the nearest lang attribute, or the browser
locale. The runtime sets the text one time, when it binds. The text does
not update.
To format many <time datetime> elements, put
data-vanilla=(Behavior::LocalTime) on a container.
The type uses chrono through autumn_web::reexports::chrono.
use autumn_plugin_vanilla::{LocalTime, TimeFormat};
use autumn_web::reexports::chrono::{TimeZone as _, Utc};
let at = Utc.with_ymd_and_hms(2026, 10, 5, 12, 0, 0).unwrap();
let html = LocalTime::new(&at).format(TimeFormat::Date).render().into_string();
assert!(html.starts_with(r#"<time datetime="2026-10-05T12:00:00Z""#), "{html}");Implementations§
Source§impl LocalTime
impl LocalTime
Sourcepub fn new<Tz: TimeZone>(at: &DateTime<Tz>) -> Self
pub fn new<Tz: TimeZone>(at: &DateTime<Tz>) -> Self
Shows at. It converts any time zone to UTC for datetime.
Sourcepub const fn format(self, format: TimeFormat) -> Self
pub const fn format(self, format: TimeFormat) -> Self
Sets the format.
Sourcepub fn fallback(self, text: impl Into<String>) -> Self
pub fn fallback(self, text: impl Into<String>) -> Self
Sets the text to show without JavaScript. The default is UTC text
that matches the format, for example 2026-10-05 12:00 UTC.
Sourcepub fn attributes(&self) -> Attributes
pub fn attributes(&self) -> Attributes
The attributes, in render order.
Source§impl LocalTime
impl LocalTime
Sourcepub fn attr(self, name: &'static str, value: impl Into<String>) -> Self
pub fn attr(self, name: &'static str, value: impl Into<String>) -> Self
Adds an extra attribute, for example id, class or
aria-label.
The name must start with an ASCII letter and contain only
ASCII letters, digits, -, _ and :. The builder ignores
(and logs) event handler names (on…), style, type and
data-vanilla… names.
Trait Implementations§
impl Eq for LocalTime
impl StructuralPartialEq for LocalTime
Auto Trait Implementations§
impl Forget for LocalTime
impl Freeze for LocalTime
impl RefUnwindSafe for LocalTime
impl Send for LocalTime
impl Sync for LocalTime
impl Unpin for LocalTime
impl UnsafeUnpin for LocalTime
impl UnwindSafe for LocalTime
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.