Hi, I'm pretty novice with Julia as a language.
I am working with sometime-series data, just a quick script to convert between formats. I have a start time for the recording and I know the sample rate. I want to create a vector of Unix timestamps so that each row of my recording can feature this field as required in the format I'm writing to.
The issue I have is that with a sample rate of say 220 Hz, the delta between each timestamp is 4.54 milliseconds. I could do all this just using floating-point numbers and then floor and convert to a unix timestamp - but I was trying to use the DateTime functions if I could, as I usually think it's best not to re-invent the wheel and try to do stuff with date and time data manually, and instead let a library handle it for you. This is what I do in most other languages to try and avoid mistakes and make my business logic more explicit.
It seems that the smallest precision for times in julia is millisceond-accuracy, and I can create an object of using Date.Milliseconds(i :: Int64) - this overall precision in the output would be fine with me, but I am then concerned about gradual drift in my recording's timestamps. Flooring this to 4ms per sample then puts the effective sample rate at 250Hz, so we have a problem after half an hour of data.
I was wondering if there's any way to do time-based arithmetic using rational or real representations. From what I know Julia is based heavily on genericism - is there a way I can use functions from the DateTime library but shoving in rational numbers in lieu of integers? Or some other known solution to this problem? Or would it simply be recommended I treat the number manually - use a floating type, generate a vector of them, then add in the unix timestamp for the first sample and round if needed only once that is done.
Thanks! Keep on slaying the snake haha.