Date / Time Class
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
You need to make your own class for ms calculation. There is no ready made classes available for that.
Every new day is another chance to change your life.
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
The COleDateTime Class[^] should work for you.
«_Superman_» _I love work. It gives me something to do between weekends.
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
Don't know if it is available to you or not or that if it can do what you need or not but check out boost::date_time[^], maybe it can help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
Mike Certini wrote:
need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms.
As a note... That is a timestamp. Timestamps always have a timezone either implicitly or explicitly. So one should always figure out what the timezone is and how it is defined.
-
I need to find the best time class to use with a program that works with a date/time number in the following format: yyyy.mm.dd hh:mm:ss.ms. Essentially, I am reading values from a flat file (CSV) into a variable and then working with the variable. Does anyone out there know the best class to use? I have researched CFileTime and CTime classes. I do not know if functions within are the best for manipulating time. CTime has been ruled out because it does not accomodate milliseconds. Are there other classes I am not aware of? Lastly is there any references (links) showing how the functions are used. The overall application involves exporting the applicable function through a DLL into an MQL4 script.
time_t curr_time = time(NULL); struct tm *pt = NULL; pt = localtime(&curr_time); char cTime[256],cTime1; sprintf(cTime,"%04d.%02d.%02d%02d:%02d:%02d",pt->tm_year+1900, pt->tm_mon+1, pt->tm_mday,pt->tm_hour,pt->tm_min,pt->tm_sec);
-
time_t curr_time = time(NULL); struct tm *pt = NULL; pt = localtime(&curr_time); char cTime[256],cTime1; sprintf(cTime,"%04d.%02d.%02d%02d:%02d:%02d",pt->tm_year+1900, pt->tm_mon+1, pt->tm_mday,pt->tm_hour,pt->tm_min,pt->tm_sec);
loveheronly, Excellent, thank you for your reply. Does the time_t container accomodate milliseconds?
-
time_t curr_time = time(NULL); struct tm *pt = NULL; pt = localtime(&curr_time); char cTime[256],cTime1; sprintf(cTime,"%04d.%02d.%02d%02d:%02d:%02d",pt->tm_year+1900, pt->tm_mon+1, pt->tm_mday,pt->tm_hour,pt->tm_min,pt->tm_sec);
After considerable research I have come up with the following solution which is 95% complete. I though cannot figure out how to report the milliseconds.
#include #using using namespace System;
using namespace System::Globalization;
using System::String;int main()
{
// Assume the current culture is en-US.
// The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds and 253 milliseconds.String\* myDateTimeValue = S"02/16/1992 12:15:12.253"; String\* expectedFormats\[\] = {S"MM/dd/yyyy hh:mm:ss.FFF"}; IFormatProvider\* culture = new CultureInfo(S"en-US", true); DateTime myDateTime = DateTime::ParseExact(myDateTimeValue, expectedFormats, culture, DateTimeStyles::AssumeLocal); Console::WriteLine(S"1) myDateTime = {0}", \_\_box(myDateTime)); system("pause"); }
-
After considerable research I have come up with the following solution which is 95% complete. I though cannot figure out how to report the milliseconds.
#include #using using namespace System;
using namespace System::Globalization;
using System::String;int main()
{
// Assume the current culture is en-US.
// The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds and 253 milliseconds.String\* myDateTimeValue = S"02/16/1992 12:15:12.253"; String\* expectedFormats\[\] = {S"MM/dd/yyyy hh:mm:ss.FFF"}; IFormatProvider\* culture = new CultureInfo(S"en-US", true); DateTime myDateTime = DateTime::ParseExact(myDateTimeValue, expectedFormats, culture, DateTimeStyles::AssumeLocal); Console::WriteLine(S"1) myDateTime = {0}", \_\_box(myDateTime)); system("pause"); }
#include <time.h>
clock_t start=clock();
//...
clock_t end=clock();
unsigned int dis_time=end-start;