|
DavidCrow wrote: named parameters
One of the the (all too few) cool things about the Ada programming language. Named parameters made for more readable and self-documenting code.
Software Zen: delete this;
|
|
|
|
|
|
I've a weird problem making me crazy !!!
I've to read a sequence of dates from a text file and convert these dates into time_t.
I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date.
So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t.
The next solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on similar functions, UnixTimeToSystemTime(), described in MSDN):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving.
In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back.
(it's very strange too, because that PC has the same date settings of mine).
I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currently timezone and daylight saving settings.
-- modified at 9:12 Thursday 3rd August, 2006
|
|
|
|
|
Nyarlatotep wrote: I've to read a sequence of dates from a text file...
What do these dates look like?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Input file is a CSV file. Dates are in dd/mm/yyyy format and I've to convert those dates into time_t without time zone o daylight saving affection ...
|
|
|
|
|
If you are reading the dates in as dd/mm/yyyy, then you can separate the three components like:
char dateToday[] = "04/08/2006";
char *pDay = strtok(dateToday, "/"),
*pMonth = strtok(NULL, "/"),
*pYear = strtok(NULL, "/"); Now you can convert those to numeric values using atoi() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
My problem is not to parse the input string date.
I parse the input date and input time and put each value into a tm struct (day, month, year, hour, minutes, seconds) and I'have used mktime() function to convert from the tm struct to time_t value.
BUT
mktime() takes into account time zone and daylight saving so, for example, if input date into the tm struct is 01/06/2006 15:00:00 (first June), the time_t date obtained from mktime() is 01/06/2006 17:00:00 (I am in GMT +1 and day light saving is in effect adding an extra hour).
Instead I want to convert the parsed date into time_t without take into account time zones and day light saving, obtaining the the same date as the input, in every time zone the program runs.
To avoid this 'problem' I've tried to use a function (see inital post) that use SystemTimeToFileTime internally, because I thought that SystemTimeToFileTime only converts from SYSTEMTIME struct to FILETIME struct without taking into account time zones and day light saving. But I was wrong, I suppose.
-- modified at 10:23 Friday 4th August, 2006
|
|
|
|
|
Nyarlatotep wrote: My problem is not to parse the input string date.
My bad. I just assumed you had the math worked out, but was having difficulty with the parsing.
Nyarlatotep wrote: ...mktime() takes into account time zone and daylight saving so...
So what is the value of tm_isdst prior to calling mktime() ?
Nyarlatotep wrote: ...the time_t date obtained from mktime() is 01/06/2006 17:00:00
What are you using to convert the time_t value to a string?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I've set tm_isdst to 0.
However to convert the string into time_t I've used these functions (insted of mktime):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
the datetime string is parsed and a SYSTEMTIME struct is filled. Then SystemTimeToUnixTime() is used to convert from SYSTEMTIME to time_t.
---------------------------------------------------
To revert time_t to a string I've used these functions :
void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
FILETIME ft;
UnixTimeToFileTime(t, &ft);
FileTimeToSystemTime(&ft, pst);
}
time_t is converted to a SYSTEMTIME by UnixTimeToSystemTime(). Then I've build a datetime string using SYSTEMTIME members.
These functions use internally FileTimeToSystemTime() and SystemTimeToFileTime() and no other OS functions.
I've thought that these two functions only convert SYSTEMTIME to FILETIME and vice versa without taking into account time zone and day light saving ...
|
|
|
|
|
I'm not sure what effect all of those other functions have on the date value, but I tried the following and got the correct output both times regardless of the value of tm_isdst :
struct tm now;
now.tm_sec = 0;
now.tm_min = 0;
now.tm_hour = 15;
now.tm_mday = 1;
now.tm_mon = 5;
now.tm_year = 106;
now.tm_wday = 5;
now.tm_isdst = 1;
printf("%s", asctime(&now));
time_t t2 = mktime(&now);
printf("%s", ctime(&t2)); I guess I'm just not understanding your problem well enough.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How can I modify the Untitled "title" that apears in my SDI aplication? I modified AFX_IDS_APP_TITLE "My aplication". But on the right of it it apears Untitled like this:
Untitled= My aplication.
So???
|
|
|
|
|
What exactly is it that you are wanting? If you are not wanting "Untitled" in the caption, see here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Serch for IDR_MAINFRAME in string table resource and insert the desired string between first and second '\n', like for example:
MyApp\nMY COOL NEW DOCUMENT\nMyApp\n\n\nMyApp.Document\nMyApp Document
-- modified at 9:01 Thursday 3rd August, 2006
PS. Tanar, tanar, dar de ce asa de nelinistit?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
... and moreover, if you want to write in the caption anything your muscles want, override CFrameWnd::OnUpdateFrameTitle, like for example:
class CMainFrame : public CFrameWnd
{
public:
virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
};
void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
SetWindowText(_T("Asta-i pohta ce-am pohtit!"));
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
|
Mai Flaviu, vrei sa te calmezi putzin?
Please, explain what's really your problem.
You cannot find in a list an item which was not inserted?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
Whats your prblem,exactly?
why you write a new thread for this object repeated?
|
|
|
|
|
What in the world are you asking here? Are you wanting to know how to populate a list control from a database? If so, there's an example of that here. If it's something else, please explain in more detail.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
It is not clear if your items -- loaded from FoxPro database -- are successfully inserted into your list control. If they appear in the list control, but FindItem apparently cannot find them, maybe they contain some additional spaces returned from FoxPro?
Maybe you should try something like this:
m_list.InsertItem(..., CString(text_from_database).Trim());
m_list.SetItemText(..., 1, CString(text_from_database).Trim());
I hope executing your program in step-by-step manner and providing reasonable details can help to solve the problem quickly.
|
|
|
|
|
I have to make an application which would access MS accesss datatbase .
I have some experience on VC++ 6 (MFC)but never worked in this field
Please if anyone could suggest me some articles or tutorials or sample codes
I would be grateful to all
|
|
|
|
|
|
SEARCH ON CODEPROJECT ARE MANY ARTICLES FOR DATABASE : CRECORDSET
AND IF YOU DONT FIND ANY WRITE ME ON bravoone@k.ro maybe i can help you ! maybe ...! i'm not so good on database ! i have problems to !!!
read my question ! and maybe you can help me to ...!!!
maybe we can help us! i dont speach english very well ! but i understend everything !
>>>>>>>>>>>>bravoone<<<<<<<<<<<
Bravoone
|
|
|
|
|
anjita wrote: I have to make an application which would access MS accesss datatbase .
See if this helps.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i dont now what is wrong but nothing hapening when i push the buton !
(the data from list control are from a database in visualfox 6.0)
maybe help this ! i dont now !
void CNcontabile::OnTest2()
{
CString sRelatia ;
m_relatia.GetWindowText(sRelatia);
LVFINDINFO stInfo = {0};
stInfo.flags = LVFI_STRING;
stInfo.psz = sRelatia;
int nItem = m_list.FindItem( &stInfo );
if( nItem != -1 )
{
// the item is in the list control
CString csSecondColumnText = m_list.GetItemText( nItem, 1 );
// set the text to the second edit box
m_credit.SetWindowText( csSecondColumnText);
}
}
i dont use anything else but this in my code and in OnInitDialog :
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVFI_STRING | LVS_EX_FLATSB);
m_list.InsertColumn(0,"Cont",LVCFMT_LEFT,90);
m_list.InsertColumn(1,"Denumire",LVCFMT_LEFT,360);
Bravoone
|
|
|
|