Skip to main content

time_zone_options

Function time_zone_options 

Source
pub fn time_zone_options(selected: &str) -> String
Expand description

The <option>s of every TIME_ZONES name, selected marked (Rails’ time_zone_select): write them in a <select>, and store the IANA name the form sends. Ocre’s own time helpers stay UTC; convert for display in the browser (Intl.DateTimeFormat with timeZone).

§Examples

let options = ocre::helpers::time_zone_options("Europe/Paris");
assert!(options.contains("<option selected>Europe/Paris</option>"));
assert!(options.contains("<option>Asia/Tokyo</option>"));

In an askama template: <select name="time_zone">{{ ocre::helpers::time_zone_options(user.time_zone.as_str())|safe }}</select>.