Time of day from decimal number

I am trying to output the time of day from the decimal part of the Julian day number but I can't get the calculations right. now.jdn() produces the current Jullian day number. Any help would be appreciated
Thanks


double jdn_time, fractpart, intpart;

jdn_time=now.jdn();
fractpart = modf(jdn_time , &intpart);

cout<< fractpart<<endl;

double seconds_in_day=(fractpart/0.00001)*.864;

cout<<seconds_in_day;
If you think about it, the fractional part of a day is a fraction of 24 hours. So if the fraction of the day is 0.5 that would be 12 hours. So you need to multiply the fraction part of the day with 24 to get hours:
1
2
3
4
5
6
	double i, f;

	double day = 0.75;
	f = modf(day, &i);
	double hour = f * 24;
	std::cout << int(hour) << '\n';

You can get minutes and seconds in a similar way.
Last edited on
Thanks ,that worked perfectly.
Topic archived. No new replies allowed.