{"id":13736093,"url":"https://github.com/mjendrusch/metric","last_synced_at":"2025-07-16T04:04:10.503Z","repository":{"id":135826697,"uuid":"122880416","full_name":"mjendrusch/metric","owner":"mjendrusch","description":"Dimensionful types for Nim.","archived":false,"fork":false,"pushed_at":"2018-08-07T13:21:57.000Z","size":10,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T05:46:10.188Z","etag":null,"topics":["dimensional-analysis","nim","si-units","units-of-measure","units-of-measurement"],"latest_commit_sha":null,"homepage":null,"language":"Nim","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/mjendrusch.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-25T21:46:41.000Z","updated_at":"2024-05-29T18:50:34.000Z","dependencies_parsed_at":"2024-01-06T12:03:32.239Z","dependency_job_id":null,"html_url":"https://github.com/mjendrusch/metric","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mjendrusch/metric","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjendrusch%2Fmetric","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjendrusch%2Fmetric/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjendrusch%2Fmetric/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjendrusch%2Fmetric/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjendrusch","download_url":"https://codeload.github.com/mjendrusch/metric/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjendrusch%2Fmetric/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265480495,"owners_count":23773741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dimensional-analysis","nim","si-units","units-of-measure","units-of-measurement"],"created_at":"2024-08-03T03:01:15.570Z","updated_at":"2025-07-16T04:04:10.459Z","avatar_url":"https://github.com/mjendrusch.png","language":"Nim","funding_links":[],"categories":["Science"],"sub_categories":["Embedded"],"readme":"# metric - bringing SI to Nim\n\n[![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble_js.png)](https://github.com/yglukhov/nimble-tag)\n\n`metric` is a small library providing type-level dimensional analysis.\nIt allows you to keep track of the physical units of your programs, and can\nbe useful for writing scientific software.\n\n## Installation\n\n`metric` has no non-standard dependencies. Just type `nimble install metric`\nand you're good to go.\n\n## A small usage example\n\n```nim\nimport metric, strformat\n\n## Let's open a block with a lot of miscellaneous units predefinded:\nwithUnits:\n  var\n    v0 = 40.0 * mile / hour # Some non-SI units of velocity.\n  echo \"v0 in miles per hour: \", fmt\"{v0 as mile / hour} [mph]\"\n  echo \"v0 in decimeters per fortnight: \",\n    fmt\"{v0 as dm / (2.0 * week)} [dm / fortnight]\"\n  echo \"v0 in SI units: \", v0\n```\n\nAs you can see, `metric` makes it easy to handle units, and never have to\nworry about keeping track of strange conversions.\n\n## Custom dimensions\n\n`metric` provides the means to handle all dimensionful quantities under the\nSI system. Dimensions taken into consideration are:\n\n* `Length`\n* `Time`\n* `Mass`\n* `Amount`\n* `Temperature`\n* `Current`\n* `Intensity`\n\nShould you need different units, you can do that, by just defining them as\n`object of BaseDimension`, with the following procs and constants:\n\n```nim\ntype\n  MyDimension = object of BaseDimension\n\nproc `$`(x: typedesc[MyDimension]): string = \"mydim\" ## \\\n  ## Define how you want your dimension's base unit to be pretty-printed.\n\nconst\n  myUnitValue = Unit[MyDimension](val: 1.0) ## The name does not matter here.\n```\n\nWith those things defined, you are good to use your units in the same way, as\nthe built-ins.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjendrusch%2Fmetric","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjendrusch%2Fmetric","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjendrusch%2Fmetric/lists"}