{"id":33936594,"url":"https://github.com/tylerreisinger/rust-float-duration","last_synced_at":"2026-03-17T20:04:53.407Z","repository":{"id":57630560,"uuid":"92317048","full_name":"tylerreisinger/rust-float-duration","owner":"tylerreisinger","description":"A library for time duration represented as a floating-point value.","archived":false,"fork":false,"pushed_at":"2023-06-01T13:51:46.000Z","size":66,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-14T02:25:11.640Z","etag":null,"topics":["duration","numerics","rust","simulation","time"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tylerreisinger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-24T17:10:32.000Z","updated_at":"2023-08-22T13:29:52.000Z","dependencies_parsed_at":"2022-09-26T20:11:31.736Z","dependency_job_id":null,"html_url":"https://github.com/tylerreisinger/rust-float-duration","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/tylerreisinger/rust-float-duration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerreisinger%2Frust-float-duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerreisinger%2Frust-float-duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerreisinger%2Frust-float-duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerreisinger%2Frust-float-duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tylerreisinger","download_url":"https://codeload.github.com/tylerreisinger/rust-float-duration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerreisinger%2Frust-float-duration/sbom","scorecard":{"id":905035,"data":{"date":"2025-08-11","repo":{"name":"github.com/tylerreisinger/rust-float-duration","commit":"7d63436d7b328499cc3d37ba8655bd816d18fef0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":1,"reason":"Found 3/27 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T17:02:31.335Z","repository_id":57630560,"created_at":"2025-08-24T17:02:31.335Z","updated_at":"2025-08-24T17:02:31.335Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30630040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["duration","numerics","rust","simulation","time"],"created_at":"2025-12-12T14:23:55.755Z","updated_at":"2026-03-17T20:04:53.402Z","avatar_url":"https://github.com/tylerreisinger.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[float_duration](https://docs.rs/float_duration) 0.3.3\n======================\n[![Build Status](https://travis-ci.org/tylerreisinger/rust-float-duration.svg?branch=master)](https://travis-ci.org/tylerreisinger/rust-float-duration)\n[![float_duration on docs.rs][docsrs-image]][docsrs]\n[![float_duration on crates.io][crates-image]][crates]\n\n[docsrs-image]: https://docs.rs/float_duration/badge.svg?version=0.3.3\n[docsrs]: https://docs.rs/float_duration/0.3.3\n[crates-image]: https://img.shields.io/crates/v/float_duration.svg\n[crates]: https://crates.io/crates/float_duration\n\nTemporal quantification using floating-point quantities.\n\nThis crate provides quantification for spans of time. Unlike the standard\n[`std::time`](https://doc.rust-lang.org/std/time/index.html) or the\n[chrono](https://crates.io/crates/chrono) crate, this crate aims\nto provide a fully featured Duration type which exposes and uses floating-point\nvalues instead of integer ones.\n\nThe existing solutions for time spans are high precision and good for displaying\nand storing time values, but they are less than convenient to use in simulations or\nmathematical contexts where a single fractional value in some unit is needed. Thus,\nthis crate was developed in order to fill that need while being maximally compatible\nwith the existing time libraries and not re-inventing the wheel. The interface aims to\nbe very similar to these libraries, just using floating point values so it may be\nused as a near drop-in replacement for existing programs that\nwould benefit from floating point durations.\n\nThe goal is to provide a type with the same set of features and flexibility as\n`std::chrono::duration` in C++ while being \"Rusty\" in design.\n\n# Usage\nPut this in your `Cargo.toml`:\n\n```\n[dependencies]\nfloat_duration = \"0.3.3\"\n```\n# Overview\n\nThis crate provides a single primary type:\n[`FloatDuration`](duration/struct.FloatDuration.html) which represents an\narbitrary distance in time with no defined start or end point.\nInternally, it stores a single `f64` holding the number of seconds the duration\nrepresents, which can be negative for a \"backward\" duration. It provides accessors\nmethods to create and read the value in various units, as well as `impl`s for many\narithmetic operators in `std::ops`.\n\n```rust\nlet timespan = FloatDuration::hours(2.5) + FloatDuration::seconds(30.0);\nassert_eq!(timespan, FloatDuration::seconds(9030.0));\nassert_eq!(timespan, FloatDuration::minutes(150.5));\n```\nAdditionally, a [`TimePoint`](duration/trait.TimePoint.html) trait is provided\nfor computing a `FloatDuration` between two objects representing a point in time.\n\n# Example Usage\n\nCompute the number of blocks in a larger interval:\n\n```rust\nuse float_duration::FloatDuration;\n\nlet time_block = FloatDuration::minutes(5.0);\nlet blocks_per_hour = FloatDuration::hours(1.0) / time_block;\n\nassert_eq!(blocks_per_hour, 12.0);\n```\n\nPerform a basic numerical integration of a mass on a spring:\n\n```rust\nuse float_duration::FloatDuration;\n\nfn acceleration(m: f64, x: f64, t: FloatDuration) -\u003e f64 {\n    0.5*m*x*x\n}\n\nfn main() {\n    let mut sim_time = FloatDuration::zero();\n    let end_time = FloatDuration::minutes(2.0);\n    let dt = FloatDuration::milliseconds(50.0);\n\n    let mut x = 2.0;\n    let mut v = 0.0;\n    let m = 1.0;\n\n    while sim_time \u003c end_time {\n        let acc = acceleration(m, x, sim_time);\n        v += acc*dt.as_seconds();\n        x += v*dt.as_seconds();\n        sim_time += dt;\n    }\n}\n```\n\nRun a function on 100 evenly spaced durations:\n\n```rust\nuse float_duration::{FloatDuration, subdivide};\n\nfn compute_value(t: FloatDuration) -\u003e f64 {\n    t.as_seconds()*t.as_seconds()\n}\n\nfor time in subdivide(FloatDuration::zero(), FloatDuration::hours(1.0), 100) {\n    println!(\"{}\", compute_value(time));\n}\n```\n\n# Library Support\n\nCurrently `float_duration` can be compiled without any dependencies, but it\nprovides optional features for interfacing with other libraries.\n\n## std::time\nThe `std::time` module is supported and `FloatDuration`\ncan be used directly with `SystemTime` and `Instant`:\n\n```rust\n// TimePoint needed for `float_duration_since`.\nuse float_duration::{FloatDuration, TimePoint};\nuse std::time::{Instant, SystemTime};\n\n\nlet start_time = Instant::now();\n// Do lengthy operation...\nlet end_time = Instant::now();\n\nprintln!(\"Took {}.\", end_time.float_duration_since(start_time).unwrap());\n```\n\n`FloatDuration` may also be converted to/from `std::time::Duration` via the\n`to_std` and `from_std` methods.\n\n## [approx](https://crates.io/crates/approx)\n`FloatDuration` provides an implementation of `approx::ApproxEq`\nfor near-equality comparisons of `FloatDuration` if the `approx` feature is enabled.\nSince `FloatDuration` uses floating point values, this should be the\npreferred way to establish equality between two duration objects.\n\n## [chrono](https://crates.io/crates/chrono)\n\nSimilar to `std::time`, computing a `FloatDuration` between any two of the same type of\ndate or time objects\nis supported via `TimePoint` trait impls, assuming the feature\n\"chrono\" is enabled.\nAdditionally, `FloatDuration` objects can be converted to/from\n`chrono::Duration` objects via the `to_chrono` and `from_chrono` methods.\n\nNote: if the `chrono` feature is enabled, the `time` feature must also be enabled\nas `chrono` directly relies on some types defined in `time`.\n\n```rust\nuse chrono::{UTC, TimeZone};\nuse float_duration::{TimePoint, FloatDuration};\n\nlet date1 = UTC.ymd(2017, 5, 25).and_hms(10, 0, 0);\nlet date2 = UTC.ymd(2017, 5, 26).and_hms(12, 0, 0);\n\nassert_eq!(date2.float_duration_since(date1).unwrap(), FloatDuration::days(1.0) +\n    FloatDuration::hours(2.0));\n```\n\n## [serde](https://crates.io/crates/serde)\n\n`FloatDuration` supports serialization with `serde`. Presently, a `FloatDuration`\nis serialized to a single `f64` value representing the number of seconds in the\nduration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerreisinger%2Frust-float-duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftylerreisinger%2Frust-float-duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerreisinger%2Frust-float-duration/lists"}