Coder Social home page Coder Social logo

notquiteamonad / date_time Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 5.0 180 KB

date_time is a high-level Rust library for use in situations where precision beyond seconds is not necessary.

License: Apache License 2.0

Rust 97.81% TOML 1.85% Nix 0.34%
datetime rust rust-library

date_time's Introduction

date_time's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

date_time's Issues

Dependabot couldn't find the branch integration

Dependabot was set up to create pull requests against the branch integration, but couldn't find it.

If the branch has been permanently deleted you can update Dependabot's target branch from your dashboard.

You can mention @dependabot in the comments below to contact the Dependabot team.

Properly document to_days and from_days

DateTuple::to_days() and DateTuple::from_days were both added in version 2.0.0 but not added to the CHANGELOG or README. They should be documented in both of those places.

Make readable strings customisable

Have a format more similar to the std::fmt string for getting readable strings.

For example, some users of the library may want to be able to output 2019 Jan 12 whereas others would prefer 12th January '19 or simply 12-1-19.

Implement next_date and previous_date for DateTuple

These will mimic the functionality of MonthTuple.next_month and MonthTuple.previous_month, but move a DateTuple on or back by one day.

This will lay the foundation for being able to add and subtract years, months, and days to and from DateTuples.

to_minutes methods for TimeTuple and Duration

Add functions to convert a TimeTuple or Duration into total number of minutes (ignoring seconds) similar to the existing to_seconds implementations.

Will simply be returning hours * 60 + seconds but could be a nice helper in some cases to avoid those using the library having to make the conversion.

Date additions do not work as common sense expects

Bug Description
Adding dates does not conform to common sense due to the limitations of a DateTuple always being a valid date.

To Reproduce
Steps to reproduce the behavior:

  1. Try to add four weeks to a date using the DateTuple Add implementation.
  2. Notice that it is impossible to create a DateTuple of four weeks because { y: 0, m: 0, d: 28 } is not a valid date; there is no zeroth month.

Screenshots
Screenshot showing steps to reproduce

Proposed Solution
Add a date duration struct similar to time_tuple::Duration so that this is possible. Implement Add<the date duration struct> for DateTuple and Sub.

In the meantime, the existing Add and Sub implementations will be removed.

DateTuple Addition/Subtraction

It would be nice to find the difference between two dates. This could include using helper methods such as to_days to facilitate this. The results should reflect exactly how many days' difference there are between.

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.