salibes
asked on
GetLocalTime in VC++
Hello all -
In VC++, the GetLocalTime() function - is there any way to break up the hours or minutes into their individual int components.
Ex: st.wHour may equal 12... and st.wMinute may equal 23.
I want to return in the wHour the 1 as one variable and the 2 as another.
In the wMinute return the 2 and the 3 as two seperate int variables.
and if it was 1:02 return (0 and 1 for hour) and (0 and 2 for minutes)
Thanks for trying to help!
In VC++, the GetLocalTime() function - is there any way to break up the hours or minutes into their individual int components.
Ex: st.wHour may equal 12... and st.wMinute may equal 23.
I want to return in the wHour the 1 as one variable and the 2 as another.
In the wMinute return the 2 and the 3 as two seperate int variables.
and if it was 1:02 return (0 and 1 for hour) and (0 and 2 for minutes)
Thanks for trying to help!
ASKER
Thank you so much. I do need the code if you don't mind because I'm not exactly sure how to extract the values. I really appreciate it.
ASKER
Thank you so much. I do need the code if you don't mind because I'm not exactly sure how to extract the values. I really appreciate it.
okay with strtok u will go something like
this is how will u get hours n minutes out of the string...
SYSTEMTIME st;
char time[20];
char *token;
int hms[3];
int count =0;
char AMPM[3];
this is what i do to make sure that locl variables dont mess
memset(time,0,20);
memset(AMPM,0,3);
get the local time
GetLocalTime(&st);
GetTimeFormat(0,LOCALE_NOU
//tokenize the time string
token = strtok( time, " :" );
while( token != NULL )
{
if(count<3)
{
hms[count]=atoi(token);
cout<<hms[count]<<endl;
}
else
{
strcpy(AMPM,token);
cout<<AMPM;
}
//increase the count
count++;
// Get next token
token = strtok( NULL, " :" );
}
continuous
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OH!
Thank you so much for all your help. That last division post did it. I owe you one. Let me know if the grade came out alright.
Thanks again,
salibes
Thank you so much for all your help. That last division post did it. I owe you one. Let me know if the grade came out alright.
Thanks again,
salibes
ignore my first n second cooment....they have nothing to do with ur problem...the code i have given in second comment is rather a silly effort as u can have hours n minutes directlyy from systime struct...the only thing it gives u is the AM/PM solution .... but this problem can be easily solved bu other means ... no need of this string manipulation...
ignore my first n second cooment....they have nothing to do with ur problem...the code i have given in second comment is rather a silly effort as u can have hours n minutes directlyy from systime struct...the only thing it gives u is the AM/PM solution .... but this problem can be easily solved bu other means ... no need of this string manipulation...
okayyyyy...thanx
the grade is alrihght...there is nothing above A;)
the grade is alrihght...there is nothing above A;)
GetLocalTime(&st)
GetDateFormat(0,DATE_SHORT
GetTimeFormat(0,LOCALE_NOU
after getting the time in chraracter string it is really easy to exract the individual values...u can use strtok on ':' or even can use CString for the purpose...
let me know if u need the code...