|
Hello
Can anyone tell me how to convert Julian date/time to Normal (standard) date/time
and back?
Any sample source code will help?
I do have some code, but the problem is, if the TIME is before 12 Noon, then it will
show the previous DAY.
i.e., if the actual time now is Sep 17th 10:30 AM
My code will give me the date as Sep 16th 10:30 AM
But if the current time is Sep 17th 10>30 PM
then it will give the exact day.
|
|
|
|
|
dipuks wrote: Can anyone tell me how to convert Julian date/time to Normal (standard) date/time
and back?
What is your Julian date's epoch?
Have you seen this?
What does your date/time value look like?
"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
|
|
|
|
|
what is a epoch?
am very new to julian date/time
|
|
|
|
|
dipuks wrote: what is a epoch?
See here.
"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
|
|
|
|
|
starting from 1 january 1899 to current date
|
|
|
|
|
Ok the problem that i am having is with calculating the time...
i.e, if the time is BEFORE NOON, that is an hour value less than 12,
then the calculation gives a negative number.
when that is added with the DAY number, it actually goes back by a day.
It seems there's no perfect way of calculating the julian time if hour is less than 12?
|
|
|
|
|
Julian dates are intervals of time in days and fractions of a day since some epoch. Again, what does your Julian date look like?
"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
|
|
|
|
|
i have to convert todays date into julian and then reconvert it back to normal date.
can you tell me how to do that?
|
|
|
|
|
With what information you've provided, no. Some Julian dates use Jan 1st of the current year as their epoch. Some use Jan 1st of 1970. Others use 1900. That detail alone would govern how you would convert from one to the other.
"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
|
|
|
|
|
what is julian time?
do you want to get current time and date?
if u want this, simply use this code,
CString szString;
SYSTEMTIME stTime;
GetLocalTime(&stTime);
szString.Format(_T("%02d-%2d-%02d\t%02d:%02d:%02d\tPHYSICALDRIVE %s\t %s\t%s\t\t%s\n"),
stTime.wDay, stTime.wMonth,stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond);
ok
Regards,
Srinivas
|
|
|
|
|
vasu_sri wrote: what is julian time?
Technically, it does not exist. Time, in terms of hours and minutes, is the fractional part of a day. For example, if your Julian date was 45.5, and the epoch was January 1st of the current year, that would be 12:00 on Feb 14th.
vasu_sri wrote: szString.Format(_T("%02d-%2d-%02d\t%02d:%02d:%02d\tPHYSICALDRIVE %s\t %s\t%s\t\t%s\n"), stTime.wDay, stTime.wMonth,stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond);
There are at least two things wrong with this: 1) stTime.wYear is a 4-digit year yet you are using %02d to print it; 2) You have 10 % characters in the format string yet are only passing 6 arguments. Since more items will be popped from the stack than were actually pushed onto it, an error is imminent.
That aside, where is the Julian date that you are wanting to convert?
"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
|
|
|
|
|
Is it possible to swap vectors between threads using std::swap() instead of iterating one vector and copying each element (given that both vectors contain the exact same type of elements)?
For example I have a structure/vector in my CMainFrame and in my CWinThread...
const struct s_list
{
CString strTimeStamp,
strStatus,
strID,
strIPRange,
strIPAddress,
strName,
strGUID,
strOS,
strResults;
BOOL bUDPReply,
bAgent;
};
std::vector<s_list> v_list;
I am assuming it would be more efficient if I could swap the elements... The iteration/copy method works but it takes a good 30 seconds and hangs the application while its plowing through all the data.
Any ideas?
Thanks,
Rob
Whoever said nothing is impossible never tried slamming a revolving door!
|
|
|
|
|
Why swap or copy? Why not share the state? Pointer to the vector that you give to the thread.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have 2 threads that are pulling different portions of the data set. I wanted to merge the data into a single place to make it easier to work with and it seemed like a good idea to copy the whole vector from ThreadA (it does most the work) then iterate it and match it against the data in ThreadB.
It may be easier to just break up the data and leave it in the threads.
Thanks for the reply,
- Rob
Whoever said nothing is impossible never tried slamming a revolving door!
|
|
|
|
|
You haven't to actually break the data: you may give to each thread a vector of pointers to the proper elements of the original vector.
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]
|
|
|
|
|
That sounds like an interesting solution, I may have to give that a go...
Thanks,
Rob
Whoever said nothing is impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote: I have 2 threads that are pulling different portions of the data set.
How about passing the thread an iterator pair (i.e. a range[^]) it can operate on. Just need to make sure the thread alters data in place and doesn't modify (i.e. add or delete elements) the vector.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I'm performing printing of reports in an MFC app in what I think is a fairly canonical way...with a CDC and CFormView with OnDraw implemented. CDC's TextOut member functions and so on are called in OnDraw().
I get inconsistent results from printer model to printer model....The margins are different, and sometimes the important parts of my documents are actually cropped. Print preview accurately represents how the document will be (often incorrectly) printed.
Is there some technique that allows me to calculate an offset for the specific model of printer in use on the fly, to compensate when drawing in OnDraw() - perhaps something to do with CDC::GetDeviceCaps()? It seems that the area of the page that my reports are "projected onto" varies somewhat (not terribly, but certainly enough for it to be a problem), but the scale is always correct.
Thanks,
Sternocera
|
|
|
|
|
When I do this in VC++ 2005:
#include <list>
class Test
{
public:
template<class T>
Test(T *a, T *b)
{
}
};
int main(void)
{
std::list<int> integerList;
Test t(integerList.begin(), integerList.end());
return 0;
}
I get the following error:
error C2660: 'Test::Test' : function does not take 2 arguments
This is an example to show the problem, but my real goal is to have a templated constructor that takes two iterators and uses them to fill an internal collection. I don't want the constructor to depend on the iterator types, i.e. the constructor shouldn't care if the iterators are from a list, vector, or raw pointers to an array.
|
|
|
|
|
I'm not sure if this causes your problem or not, but as far as i know begin() and end() don't return pointers to iterators while your constructor takes two pointers. Test(T *a, T *b) .
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Code-o-mat wrote: I'm not sure if this causes your problem or not, but as far as i know begin() and end() don't return pointers to iterators while your constructor takes two pointers. Test(T *a, T *b).
Yup, that was exactly the problem. Thanks!
|
|
|
|
|
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
This fix the compiler errors
#include <stdio.h>
#include <list>
template <class T>
class Test
{
public:
Test(T a, T b)
{
}
};
int main(void)
{
std::list<int> integerList;
Test<std::list<int>::iterator> t(integerList.begin(), integerList.end());
return 0;
}
However, it is not what you're looking for, I suppose.
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]
|
|
|
|
|
Alright, this is the thing... I have to create an Array for a number of objects in a setting with polymorphism.
Each object in the array needs to do the same thing... so I figure I can just create a loop for each item in an array.
Now, the method is called the same thing because of Polymorphism/inheritance
Although the method is placed somewhere else for each object...
so I have 10 classes.
the Base class is called: Animals
From Animals come: Marine, Reptiles, walkers
From there we have 6 different types of animals deriving from those.
#include "Gazelles.h"
#include "Goldfish.h"
#include "Sharks.h"
#include "Snakes.h"
#include <iostream>
using namespace std;
int main(int argc,char* argv[])
{
Animals *ourAnimals[6];
Animals *goldfish = new Goldfish();
Animals *crocodile = new Crocodiles();
Animals *elephant = new Elephants();
Animals *gazelles = new Gazelles();
Animals *shark = new Sharks();
Animals *snakes = new Snakes();
ourAnimals[0]=goldfish;
ourAnimals[1]=crocodile;
ourAnimals[2]=elephant;
ourAnimals[3]=gazelles;
ourAnimals[4]=shark;
ourAnimals[5]=snakes;
for(i=0;i<6;i++)
{
ourAnimals[i]
}
return 0;
}
each animal has converse, I am a bit of a noob with this obviously, so how do I get each object in the array to do what I want it to do?
|
|
|
|
|
Sivyo wrote: how do I get each object in the array to do what I want it to do?
How about something like:
Animal *ourAnimals[3];
ourAnimals[0] = new Goldfish();
ourAnimals[1] = new Crocodile();
ourAnimals[2] = new Elephant();
for (int i = 0; i < 3; i++)
ourAnimals[i]->converse();
"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
|
|
|
|