- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found this code in C, but i dont't undestand at all, because
i can't use memcpy function in fortran. Please, i need help with this
VOID GetTimeDifference(const PSYSTEMTIME pst1, const PSYSTEMTIME pst2, int* piHours, int* piMins, int* piSecs)
{
static const ULONGLONG FT_SECOND = ((ULONGLONG) 10000000);
static const ULONGLONG FT_MINUTE = (60 * FT_SECOND);
static const ULONGLONG FT_HOUR = (60 * FT_MINUTE);
static const ULONGLONG FT_DAY = (24 * FT_HOUR);
// Convert each SYSTEMTIME structure into a FILETIME one...
FILETIME ft1, ft2;
SystemTimeToFileTime(pst1, &ft1);
SystemTimeToFileTime(pst2, &ft2);
// Convert to large integers...
ULARGE_INTEGER li1 = {0};
memcpy(&li1, &ft1, sizeof(FILETIME));
ULARGE_INTEGER li2 = {0};
memcpy(&li2, &ft2, sizeof(FILETIME));
// Subtract the two dates...
ULONGLONG ullNanoDiff = li2.QuadPart - li1.QuadPart;
// FILETIME's measure the number of 100-nanosecond intervals. Convert this to seconds...
long lSecDiff = (long) (ullNanoDiff / FT_SECOND);
// Finally, convert seconds to minutes and hours, if necessary...
*piHours = (int) lSecDiff / 3600;
lSecDiff = lSecDiff % 3600;
*piMins = lSecDiff / 60;
*piSecs = lSecDiff % 60;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have a solution for your problem but I have a routine which might help you to work with Windows' FILETIME and SYSTEMTIME structures. There is a bit of German in it:
Zeit = time
deutsch = German
I hope this helps you somewhat.
Jrg Kuthe
www.qtsoftware.de
SUBROUTINE qtConvertFileTimeToSystemTime( FT, ST, iLanguage, strZeit )
! converts 64 Bit Filetime (in FT) into system time.
USE DFWINTY
IMPLICIT NONE
TYPE (T_FILETIME), INTENT(IN):: FT
TYPE (T_SYSTEMTIME), INTENT(OUT) :: ST
INTEGER, INTENT(IN):: iLanguage ! 1: deutsch, 2: english
CHARACTER (*), INTENT(OUT) :: strZeit ! LEN(strZeit) > 27 erforderlich
INTEGER iRet
CHARACTER (3) :: c3DayOfWeek(2,0:6) = (/'So', 'Sun', 'Mo', 'Mon', &
'Di', 'Tue', 'Mi', 'Wed', &
'Do', 'Thu', 'Fr', 'Fri', 'Sa', 'Sat' /)
INTERFACE
FUNCTION FileTimeToSystemTime( lpFileTime, lpSystemTime )
USE DFWINTY
integer(BOOL) :: FileTimeToSystemTime ! BOOL
!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'FileTimeToSystemTime' :: FileTimeToSystemTime
!DEC$ ATTRIBUTES REFERENCE, IGNORE_LOC, ALLOW_NULL :: lpFileTime
TYPE (T_FILETIME) lpFileTime ! FILETIME* lpFileTime
!DEC$ ATTRIBUTES REFERENCE, IGNORE_LOC, ALLOW_NULL :: lpSystemTime
TYPE (T_SYSTEMTIME) lpSystemTime ! LPSYSTEMTIME lpSystemTime
END FUNCTION
END INTERFACE
IF ( LEN(strZeit) < 28 ) RETURN
iRet = FileTimeToSystemTime( FT, ST )
IF ( iLanguage == 1 ) THEN
WRITE (strZeit, 10000)c3DayOfWeek(iLanguage, ST % wDayOfWeek), &
ST % wDay, ST % wMonth, ST % wYear, &
ST % wHour, ST % wMinute, ST % wSecond, ST % wMilliseconds
10000 FORMAT(A2, 1X, 2(I2.2, '.'), I4, 1X, 3(I2.2, ':'), I4.4)
ELSE IF( iLanguage == 2 ) THEN ! english
WRITE (strZeit, 10000)c3DayOfWeek(iLanguage, ST % wDayOfWeek), &
ST % wMonth, ST % wDay, ST % wYear, &
ST % wHour, ST % wMinute, ST % wSecond, ST % wMilliseconds
10010 FORMAT(A3, 1X, 2(I2.2, '.'), I4, 1X, 3(I2.2, ':'), I4.4)
ELSE
RETURN
END IF
RETURN
END
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FUNCTION julian_date (yyyy, mm, dd) RESULT (julian)
IMPLICIT NONE
! converts calendar date to Julian date
! cf Fliegel & Van Flandern, CACM 11(10):657, 1968
! example: julian_date(1970,1,1)=2440588
INTEGER,INTENT(IN) :: yyyy,mm,dd
INTEGER :: julian
julian = dd - 32075 + 1461*(yyyy + 4800 + (mm - 14)/12)/4 + &
367*(mm - 2 - ((mm - 14)/12)*12)/12 - &
3*((yyyy + 4900 + (mm - 14)/12)/100)/4
END FUNCTION julian_date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tanks for your help buddies,I can't reply you before,I had problems with internet.but I was wondering if those formulas can help me with dates before 1971?
I was wondering too what happens if I substract each one of the fields of the filetime structure. i.e. date1 = filetime2%dwLowDateTime - filetime1%dwLowDateTime or date2 = filetime2%dwHighDateTime - filetime1%dwHighDateTime.Does any of these values( date1, date2) , give me the correct number of days between the two dates? or I'm lost?
I copy the help in the MSDN help abuot filetime struct.
var ArrowOffPath="http://i.msdn.microsoft.com/Platform/Controls/DropDownFilter/resources/arrow-off.gif"; var ArrowOnPath="http://i.msdn.microsoft.com/Platform/Controls/DropDownFilter/resources/arrow-on.gif"; var strConstLangFilterAll ="All"; var strConstLangFilterMulti ="Multiple"; var strConstLangFilterNone ="None"; var strConstLangFilterText ="Language Filter"; var oMTPS_DD_ImgArrow = document.getElementById("ctl00_LibFrame_ddfPlaceHolder_MTPS_DD_ImageArrow"); var oMTPS_DD_PanelLink = document.getElementById("ctl00_LibFrame_ddfPlaceHolder_Mtps_DropDownFilterText"); var oMTPS_DD_Div = document.getElementById("ctl00_LibFrame_ddfPlaceHolder_DropDownFilterMain"); var oMTPS_DD_PopUpDiv = document.getElementById("ctl00_LibFrame_ddfPlaceHolder_Mtps_DropDownPopUp");FILETIME StructureContains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
Syntax
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime; } FILETIME,
*PFILETIME;Members
- dwLowDateTime
The low-order part of the file time.
- dwHighDateTime
The high-order part of the file time.
Remarks
To convert a FILETIME structure into a time that is easy to display to a user, use the FileTimeToSystemTime function.
It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should copy the low- and high-order parts of the file time to a LARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.
Do not cast a pointer to a FILETIME structure to either a LARGE_INTEGER* or __int64* value because it can ca use alignment faults on 64-bit Windows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
function FileTimeToSystemTime which
does exactly what its name promises. You
can then build a Julian date from the systemtime
components. The Julian formula works with
any date after 1/1/0000, but you are unlikely
to encounter filetimes from 1971, since this
predates personal computers by about 10
years.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI, FOR SOME REASON THE JULIAN DATE FUNCTION DOESN'T WORK WELL WHITH ME, I THINK IT WORKS WELL BUT, INSTEAD I CAN RESOLVE MY PROBLEM BY OTHER WAY, IT IS BY CREATING A UNION IN THIS WAY:
type numero
union
map
integer*4 lw, hw
end map
map
integer*8 qp
end map
end union
end type
I COPY TWO PARTS OF THE FILETIME STRUCTURE IN THE LW AND HW PARTS OF MY UNION, AND THE QP PART RETURNS THE JOINED INTEGER. THEN I CAN DO OPERATIONS TO GIVE METHE NUMBER OF DAYS.
SO TANKS FOR YOUR HELP, I POST THIS BECAUSE CAN BE ANOTHER WAY TO HELP YOUIF YOU HAVETHIS PROBLEM.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page