Add Milliseconds unit to DateTime Axis#539
Conversation
|
After a little thought I came up with the idea that it would be nice to split the I'm ready to do this, but I can't decide how best. I'm waiting for your input. |
|
Hi @StendProg, your idea to add subdivisions of seconds to the DateTimeUnit enum is perfect. I was not familiar with these words (I had to look them up to be sure they were real), but it appears these units of time have names we can use:
Thank you for working on this! I see how this PR relates to #537, and I also very much appreciate your recent efforts responding to issues while I was busy over the last few days. |
|
The naming system you suggested made the confusion in my head surprisingly simple. |
|
I would have use for microseconds (µs) at 10^-6 seconds. And since this library is targeted towards science I expect that nano (10^-9), pico, femto (10^-12), and atto (10^-15) prefices are likely to be useful. There are prefices for even smaller numbers but I've never seen them used. It's also worth noting that in some contexts it's more clear to write I don't think you can even go to attosecond precision thanks to the width of a double, which means anyone going this precise should probably use a conventional axis and rescale it (i.e. multiply by 10^-x) instead of using a DateTime axis. I don't know how OLE Date runs its affairs and I would suggest not changing to another system (e.g. Unix time) for backwards compatibility. So my recommendation is to support the smallest prefix that can be reliably expressed as an OLE Date with an FP64 double. If it's a very small prefix it might need configuration so people don't get confused by attoseconds. |
☝️ this! I agree that some scientists may want to plot data with femtosecond precision. They will probably use This raises an interesting question though, how precise is a DateTime.Ticks documentation says, "The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 in the Gregorian calendar" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'll just add my little bit, since my suggestion surprisingly kicked off this thread. I'm presently working in samples of audio, which when displayed should labelled as hours, minutes, seconds and milliseconds - with the leading zeros included. Regardless of the file format (MP3 or wave), the samples rates of audio files can vary anywhere from the common ones as 48000, 44100 and all the way up to 192kHz per second. I would think that the display conversion for only the X-axis text label should be enough, while still keeping the plot unchanged while still being able to show and zoom in to the individual samples. I'm amazed that you are all jumping in on this. Go team! |
I am also thinked that precise of OA date low, but found on StackOverflow:
|
I got a little bit bamboozled, but I think the difference comes from me rounding the number of significant digits midway through. If you do as he did you find that you need 16 bits for the day and that leaves 37 bits for the fractions of a day. I assumed it would always be 15 significant digits, but with FP64 it can be 15-17, so my rounding came back to bite me. The stackoverflow answer: https://stackoverflow.com/a/13922172/3513171 |
|
@Benny121221 As far as I understand OA date, at one moment the accuracy will be exactly the same as you indicated initially (sooner or later this moment will come) :-) |
…ing separete class for each DateTimeUnit.
…y additional formating later
…o can raise overflow
… prevent later conversion)
|
Hi @StendProg, this is an excellent refactor of the DateTimeTicks module! I am happy to see the factory pattern here, and these small classes really help readability and maintainability. This improvement is useful for #537 too. It's been a few days since your last commit - is this ready for me to review and merge into master, or do you intend to continue working on it? |
|
Hi Scott (@swharden),
It's ready. There are 2 unresolved issues that I want to pass on to you.
|
I think the line that caused that behavior is: The 3 line behavior was not intended, and is probably the result of locales where the string contains more than 1 space. I recognize that hard-coding a string search/replace with a line break is bad practice for internationalization, and am happy the new code no longer does things like this! Thanks again for this excellent PR |
In fact, I tried to keep the original behavior, because I did not fully understand it, and it is difficult to test for many cultures at once. I think it's a good idea to write unit tests that count the number of lines in different cultures, with the current design it should be easier. I'll do it some other day. |
Purpose:
Current
DateTime Axisminimal unit is second.This PR add
decisecond,centisecondandmillisecondunits to DateTimeAxis.There is possible to zoom into second interval and get millisecond ticks on DateTimeAxis. #537
There is no culture invariant time specifier to display
milliseconds, so i hardcoded this formats:hh:mm:ss.f- decisecondhh:mm:ss.ff- centisecondhh:mm:ss.fff- millisecondAdditional refactor DateTime Ticks module.
New functionality (code):
There is no new
APIin this PR.New functionality (image):