Skip to content

Conversation

@tomgco
Copy link
Contributor

@tomgco tomgco commented Sep 3, 2015

I needed to print out a fixed precision to ensure that the output would always match no matter what the input was, for example 70ms needs to output .070 and 0ms needs to print .000.

I am really new to rust and I hope that this is OK.

I tried to create a macro that would construct Nanosecond{3,6,9} however to do that I needed to use std::concat_idents! which was unstable so you are left with a more verbose matching. If you have any improvements let me know on this PR let me know.

Thanks.

lifthrasiir added a commit that referenced this pull request Sep 5, 2015
New formatters %.3f, %.6f, %.9f
@lifthrasiir lifthrasiir merged commit 37c7f78 into chronotope:master Sep 5, 2015
@lifthrasiir
Copy link
Contributor

@tomgco I was thinking hard about the generic width/precision specification (which I didn't seriously try to adapt, but glibc and some others have that and I assume we eventually need to do so), but #46 will force pushing a new version to crates.to anyway and I don't see any further reason to delay accepting this except that we will want to do this more generally. Thank you and sorry for delay!

lifthrasiir added a commit that referenced this pull request Sep 6, 2015
- Added `%.3f`, `%.6f` and `%.9f` specifier for formatting fractional seconds
  up to 3, 6 or 9 decimal digits. This is a natural extension to the existing `%f`.
  Note that this is (not yet) generic, no other value of precision is supported. (#45)

- Forbade unsized types from implementing `Datelike` and `Timelike`.
  This does not make a big harm as any type implementing them should be already sized
  to be practical, but this change still can break highly generic codes. (#46)

- Fixed a broken link in the `README.md`. (#41)

- Tons of supporting examples for the documentation have been added. More to come.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants