Giter VIP home page Giter VIP logo

tzfile's People

Contributors

amoskvin avatar kennytm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tzfile's Issues

impl FromStr for Tz

this would enable more cases like accepting user provided timezone identifiers

DateTime<ArcTz> serializes into the wrong format

Chrono's Serialize implementation uses Debug formatting for Serialize, and assumes that it will produce valid RFC 3339: https://docs.rs/chrono/0.4.19/src/chrono/datetime.rs.html#2066
https://docs.rs/chrono/0.4.19/src/chrono/datetime.rs.html#720

ArcTz's offset prints the time zone's name in Debug, not the offset, so DateTime serializes into an incorrect format.

For example:

use chrono::{DateTime, NaiveDate, TimeZone};
use serde::Serialize;
use tzfile::ArcTz;

#[derive(Debug, Serialize)]
pub struct Foo {
    pub date: DateTime<ArcTz>,
}

fn main() {
    let tz = ArcTz::named("Europe/Budapest").unwrap();
    let dt = tz.from_utc_datetime(&NaiveDate::from_ymd(2021, 3, 11).and_hms(17, 49, 32));
    println!("{:?}", dt.offset());
    let foo = Foo { date: dt };
    let j = serde_json::to_string(&foo).unwrap();
    println!("{}", j);
}

This prints {"date":"2021-03-11T18:49:32CET"}, which isn't valid RFC3339.

Respect `TZDIR` environment variable

Tz::named always loads its time zones from /usr/share/zoneinfo/, even if TZDIR is set. From what I can tell, glibc respects this variable.

This would be useful since NixOS uses a nonstandard time zone directory location (/etc/zoneinfo/ or /etc/static/zoneinfo/) which this library currently can't find.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.