Giter VIP home page Giter VIP logo

zig-tzif's Introduction

Zig TZif

This repository implements TZif parsing, according to RFC 8536.

Usage

Take a look at the examples to get an idea of this library works. I recommend starting with the localtime example.

Add it as a package

To start, add zig-tzif to your build.zig.zon:

.{
    .name = "your-project",
    .version = "0.1.0",
    .dependencies = .{
        .tzif = .{
            .url = "https://github.com/leroycep/zig-tzif/archive/fdac55aa9b4a59b5b0dcba20866b6943fc00765d.tar.gz",
            .hash = "1220459c1522d67e7541b3500518c9db7d380aaa962d433e6704d87a21b643502e69",
        },
    },
}

Then, add zig-tzif to executable (or library) in the build.zig:

const Build = @import("std").Build;

pub fn build(b: *Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    // Get the tzif dependency
    const tzif = b.dependency("tzif", .{
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        .name = "tzif",
        .root_source_file = .{ .path = "tzif.zig" },
        .target = target,
        .optimize = optimize,
    });

    // Add it as a module
    exe.addModule("tzif", tzif.module("tzif"));

    b.installArtifact(exe);
}

Useful functions

tzif.parseFile(allocator, filename) !TimeZone

tzif.parse(allocator, reader, seekableStream) !TimeZone

TimeZone.localTimeFromUTC(this, utc_timestamp) ?ConversionResult

Caveats

  • This library has not been rigorously tested, it might not always produce the correct offset, especially for time zones that have changed between different Daylight Savings schemes.
  • Does not support version 1 files. Files must be version 2 or 3.

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.