Request: juce::Time( double )


#1

I’m probably approaching this the wrong way, but i’m hoping to be able to create some ISO 8601 timestamps using Time::getMillisecondCounterHiRes(); There’s no simple way to create a Time object using the output of Time::getMillisecondCounterHiRes() and then be able to call Time::toISO8601()

Ideally, something like this:

juce::String s = Time(Time::getMillisecondCounterHiRes()).toISO8601(true);

I did see this static method tho:

static int64 Time::secondsToHighResolutionTicks(double 	seconds)

are we supposed to do something like this:

auto s = Time( Time::secondsToHighResolutionTicks( Time::getMillisecondCounterHiRes() * 1000 ) ).toISO8601(true);

#2

just to update this. So, it’s not so much a request, but more that I’m trying to figure out how to combine my midi recording scheme here: MidiMessageSequence -> MidiFile question with timestamps

this was the solution i came up with:

MainContentComponent::MainContentComponent(const Time& s)
{
    sessionID = s;
    DBG( sessionID.toISO8601(true) );
    start_time_hi_res = Time::getMillisecondCounterHiRes() ;
    startTimer(5 * 1000 ); // 5 seconds
    setSize (600, 400);
}

void MainContentComponent::timerCallback() {
    auto th = Time::getMillisecondCounterHiRes();
    RelativeTime r( (th - start_time_hi_res) / 1000 );
    auto i = sessionID + r;
    DBG( i.toISO8601(true) );
}

//output:

2017-04-21T15:35:33.123-04:00
2017-04-21T15:35:38.244-04:00
2017-04-21T15:35:43.245-04:00
2017-04-21T15:35:48.246-04:00
2017-04-21T15:35:53.247-04:00