-
Julian day of year
Folks,
I'm trying to program some code that will return me the julian day of year, that means the day from 1 to 365 (or 366 in leap years).
All I need the specific part of code to do is: Get TODAY's Julian day value and put it as a number, int variable would do.
Thanks for the help,
-
Show us what you got so far
-
-
Nothing yet
I guess I should have asked how to use the time.h functions... Actually, I have very few knowledge on those functions work.
Is there any way I can just command the code to get me the day of the current date and convert it to julian myself ???
Thanks and sorry for asking the question in a bad way...
-
Day of year
After reading that, I can only feel myself a little more dumb.
So what I really need is the "day of year". Got a clue or have a nice tutorial I can dive in reading to learn the time.h funcions ???
Thanks
-
Code:
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t now;
if ( time(&now) != (time_t)(-1) )
{
struct tm *mytime = localtime(&now);
if ( mytime )
{
char jday [ 4 ];
if ( strftime(jday, sizeof jday, "%j", mytime) )
{
printf("mytime->tm_yday = %d, jday = \"%s\"\n", mytime->tm_yday, jday);
}
}
}
return 0;
}
/* my output
mytime->tm_yday = 165, jday = "166"
*/
-
Thanks
Thanks everyone for helping.
Dave, I was insipired by one post of yours in another thread and it worked. Thanks too!!
See ya