Convert a unix timestamp (seconds) to a struct {year, month, day, hour, minute, second, weekday}.

Overview

uts2ts

Continuous Integration Continuous Deployment GitHub Tag Crate Release Documentation

uts2ts is a simple function that does only one thing:

It converts a unix timestamp to something slightly more useful. ;-)

So why then? Well, it's not always warranted to pull in a myriad of dependencies when you need this one, little thingy.

For complex time and date calculations and manipulations, please refer to the more functional complete crates chrono and time.

Please note that the as_string() method is just a quick way of generating a human readable date/time string that

  • is unambiguous and close to ISO 8601 (or RFC 3339)
  • can be used as an example how to write your own formatting function
  • is NOT an attempt to reinvent all the goodies other crates provide

Examples

use uts2ts::uts2ts;

fn main() {
    let ts = uts2ts(204158100);

    // Timestamp { year: 1976, month: 6, day: 20, hour: 22, minute: 35, second: 0, weekday: 0 }
    println!("{:?}", ts);

    // 1976-06-20 22:35:00
    println!("{}", ts.as_string());
}
You might also like...
Easy access of struct fields in strings using different/custom pre/postfix:
Easy access of struct fields in strings using different/custom pre/postfix: "Hello, {field}" in rust

Easy access to struct fields in strings šŸ  add strung to the dependencies in the Cargo.toml: [dependencies] strung = "0.1.3" šŸ¦€ use/import everything

A lightweight, zero-dependency struct diffing library which allows changed fields to be collected and applied

structdiff A lightweight, zero-dependency struct diffing library which allows changed fields to be collected and applied. Derive Difference on a struc

A crate providing a MemoryCell struct, which stores a current and previous value.

memcell What is a MemoryCell? A MemoryCell is a struct containing both a current and optional previous value. Definition #[derive(Debug, Clone)] pub s

Statically verified Rust struct field names as strings.

field Statically verified struct field names as strings. See the documentation for more details. Installation Add the following to your Cargo manifest

A Rust curses library, supports Unix platforms and Windows

pancurses pancurses is a curses library for Rust that supports both Linux and Windows by abstracting away the backend that it uses (ncurses-rs and pdc

Reviving the Research Edition Unix speak command

This repository contains the source code of Unix speak program that appeared in the Third (1973) to Sixth (1975) Research Unix editions, slightly adjusted to run on a modern computer. Details on the code's provenance and the methods employed for reviving it can be found in this blog post.

Spawn multiple concurrent unix terminals in Discord

Using this bot can be exceedingly dangerous since you're basically granting people direct access to your shell.

fcp is a significantly faster alternative to the classic Unix cp(1) command
fcp is a significantly faster alternative to the classic Unix cp(1) command

A significantly faster alternative to the classic Unix cp(1) command, copying large files and directories in a fraction of the time.

A tool for automating terminal applications in Unix.

expectrl A tool for automating terminal applications in Unix. Using the library you can: Spawn process Control process Expect/Verify responces It was

Owner
Helmut K. C. Tessarek
Always trying to break stuff. 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944
Helmut K. C. Tessarek
Timestamp-orderable UUIDs for Python, written in Rust.

UUIDT Timestamp-orderable UUIDs for Python, written in Rust. Installation pip install uuidt Usage import uuidt # Create a new UUIDT u = uuidt.new('my

Isaac Harris-Holt 7 Mar 12, 2023
zman is a CLI year (time) progress that small, fast, and just one single binary.

zman zman is a CLI year (time) progress that small, fast, and just one single binary. Features Show year progress Show month, and week progress Show r

azzamsa 17 Dec 21, 2022
Advent of Code 2021, in rust this year

Advent of Code 2021 ?? Solutions for the 2021 edition of Advent of Code. This year, I try to do this in Rust ?? . I discover the language, so do not t

Florian Gaudin-Delrieu 1 Aug 12, 2022
Same procedure as every yearā€¦ right?

Advent of Code 2022 solutions What this repository is This repository contains solutions to Eric Wastls Advent of Code 2022. Thank you, Eric! While th

Patrick 3 Dec 15, 2022
Advent of Code, this year I will attempt the 25 different languages challenge

Advent of Code 2022 As this is my third year doing Advent of Code, this time I will try the 25 Different Languages Challenge, which is solving the pro

Andreu Vall HernĆ ndez 7 Dec 27, 2022
Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language)

Advent of Code 2022: 15/25 langs Iā€™ll try to solve this Advent of Code using different language for each day. Any programs needed to run the code will

Max ā€œGoldsteinā€ Siling 2 Dec 15, 2022
Advent of Code, different language each day

I forgor ?? Advent Of Code 2022 Using a different language each Day!! (For obvious reason some solutions might be absolute shitcode, since I'm learnin

Ven 8 Dec 11, 2022
A simple cli tool for generating quotes in your terminal from Kanye west. Start the day out strong.

Kanyey A simple cli tool for generating quotes in your terminal from Kanye West. Install Just do cargo install kanyey and be blessed. Bonus: throw it

null 3 Sep 29, 2023
Happy April Fools' Day!

cargo-cargo Happy April Fools' Day! cargo install cargo-cargo And then you can: cargo cargo run Or you can: cargo cargo cargo cargo cargo run Or: c

OpenSound 7 May 7, 2024
Parse command line arguments by defining a struct.

StructOpt Parse command line arguments by defining a struct. It combines clap with custom derive. Documentation Find it on Docs.rs. You can also check

Guillaume P. 2.6k Jan 5, 2023