Julian date
-
Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .
Vijjuuuuuuuuu........... wrote:
is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ .
Yes (and it possibly returns
09034
for your input). :rolleyes:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Vijjuuuuuuuuu........... wrote:
is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ .
Yes (and it possibly returns
09034
for your input). :rolleyes:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You can roll your own one. What are your doubts while doing that? I recall for you the needed steps (if you aren't using MFC or ATL). You have to:
- Parse the string to obtain
day-of-month
,month
andyear
from the string. - Convert
day-of-month
andmonth
today-of-year
. - Align properly
year
andday-of-year
values in the resulting number.
In the above task, only point(2) is a bit tricky because of leap years. Using
MFC
orATL
would make your life easier.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Monday, February 23, 2009 4:11 AM
- Parse the string to obtain
-
Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .
it depends on what you mean by julian date - since the term is most often miss-used these days. If you mean 'the day number as a number starting counting from the 1st of Jan in the Current year', then you need to follow the advice of our trusted and esteemed colleague CPallini If you mean since an arbitrary point in time - such as is used by astronomers etc, ie 4713BC, then, part one of CPallini's response still applies, then you feed the results of the parse into something like :- http://www.silverglass.org/code/Date.html[^] 'g'
-
Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .
-
Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .
Vijjuuuuuuuuu........... wrote:
...to julian date...
Which one?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
just use scansf grab the constituent parts and throw it into a SYSTEMTIME struct. Just rember that scanf assumes int * and the systemtime struct is all word size objects.
a programmer traped in a thugs body
DWORD Month,Day,Year,Hour,Minute,Second; //Initalize the values and the structure to zero Month = Day = Year = Hour = Minute = Second = 0; memset(&ST,0,sizeof(ST)); //Fix This use the stram reader so I can read the write size //Parse out the date with sscanf sscanf_s(Val.c_str(),"%d/%d/%d %d:%d:%d ",&Day,&Month,&Year,&Hour,&Minute, &Second); //reassign the values into the structure ST.wDay = (WORD) Day ; ST.wMonth = (WORD) Month ; ST.wYear = (WORD) Year ; ST.wHour = (WORD) Hour ; ST.wSecond = (WORD) Second; ST.wMinute = (WORD) Minute;
a programmer traped in a thugs body
-
it depends on what you mean by julian date - since the term is most often miss-used these days. If you mean 'the day number as a number starting counting from the 1st of Jan in the Current year', then you need to follow the advice of our trusted and esteemed colleague CPallini If you mean since an arbitrary point in time - such as is used by astronomers etc, ie 4713BC, then, part one of CPallini's response still applies, then you feed the results of the parse into something like :- http://www.silverglass.org/code/Date.html[^] 'g'