c++ ctime 如何转为delphi 类型!(50分)

  • 主题发起人 主题发起人 13708782004
  • 开始时间 开始时间
1

13708782004

Unregistered / Unconfirmed
GUEST, unregistred user!
//电度参数表
typedef struct scada_kwh
{
BYTE Periodpolicy; //时段策略号
CTime DayAccStartT; //日累计电度起始时间
char RelateInfName[16]; //相关点信息名
BYTE IsExist; //是否存在
}scada_kwh,*LPscada_kwh;
请问,ctime 转成delphi的那个类型啊?
 
CTime的声明在哪里?看看他的声明类型啊。
 
ctime 在vc 是标准类型啊
 
char * ctime ( const time_t * timer )

Convert time_t value to string.
Converts timer to a string containing time and date adjusted to local time zone in readable format.
timer is an integer value of type time_t defined as long int by default in most compilers, and usually returned by a call to time function.
The returned string has the following format:


Www Mmm dd hh:mm:ss yyyy
where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year. The string is followed by a new-line character (/n) and a terminating null-character, conforming a total of 26 characters.
Parameters.

tmptr
pointer to a time_t value, usually returned by time function.
Return Value.
A pointer to the string containing the date and time information in readable format.
The string pointed is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the content of the string is overwritten.
ctime also uses internally the buffer used by gmtime and localtime as return value, so a call to this function will overwrite this.

Portability.
Defined in ANSI-C.


Example.


/* ctime example */
#include <stdio.h>
#include <time.h>

int main ()
{
time_t rawtime;

time ( &rawtime );
printf ( &quot;Current date and time are: %s&quot;, ctime (&rawtime) );

return 0;
}

Output:
Current date and time are: Sat May 20 16:05:33 2000
 
ctime是字符串,string类型的,现在明白在delphi里面该申明为什么类型了吧!
 
难道是
ctime :array[1..26] of char;
 
ctime :array[1..4] of char

好象又点对
 
你直接用delphi里面的string不就可以了吗?
 
用string 离谱多了!
用longint 还勉强,虽然时间没有读出,但RelateInfName[16]
//相关点信息名
IsExist
//是否存在 这2个后面的字段还可以正常读出!
 
帮帮我啊,各路朋友!
 
These constructors create a new instance of a CTime object initialized with the specified absolute time
based on the current time zone.

CTime( );

CTime(
time_t time );

CTime(
int nYear,
int nMonth,
int nDay,
int nHour,
int nMin,
int nSec,
int nDST = –1 );

CTime(
WORD wDosDate,
WORD wDosTime, |
int nDST = –1 );

CTime(
const CTime& timeSrc );

CTime( const SYSTEMTIME& sysTime,
int nDST = –1 );

CTime( const FILETIME& fileTime,
int nDST = –1 )

Parameters
timeSrc
Indicates a CTime object that already exists.
time
Specifies a time_t time value, which is the number of seconds after January 1, 1970 UTC. Be aware that this will be adjusted to your local time. So if you create a CTime object by passing a parameter of 0, CTime::GetMonth will return 12 if you are in New York.
nYear, nMonth, nDay, nHour, nMin, nSec
Indicates the date and time values to be copied into the new CTime object.
nDST
Indicates whether daylight savings time is in effect. MFC for Windows CE only supports nDST set to a value less than 0, this is the default. It will automatically detect whether standard time or daylight savings time is in effect.
wDosDate, wDosTime
Specifies the MS-DOS date and time values to be converted to a date/time value and copied into the new CTime object.
sysTime
Specifies a SYSTEMTIME structure to be converted to a date/time value and copied into the new CTime object.
fileTime
Specifies a FILETIME structure to be converted to a date/time value and copied into the new CTime object.
Remarks
Each constructor is described below:

CTime( )
Constructs an uninitialized CTime object. This constructor allows you to define CTime object arrays. You should initialize such arrays with valid times prior to use.
CTime( time_t ), Constructs a CTime object from a time_t type.
CTime( const CTime& )
Constructs a CTime object from another CTime value.
CTime( int, int, etc.)
Constructs a CTime object from local time components with each component constrained to the following ranges: Component Range
nYear 1970–2999
nMonth 1–12
nDay 1–31
nHour no constraint
nMin no constraint
nSec no constraint


This constructor makes the appropriate conversion to UTC. The Debug version of the Microsoft Foundation Class Library asserts if one or more of the year, month, or day components is out of range. It is your responsibility to validate the arguments prior to calling.

CTime( WORD, WORD )
Constructs a CTime object from the specified MS-DOS date and time values.
CTime( const SYSTEMTIME& )
Constructs a CTime object from a SYSTEMTIME structure.
CTime( const FILETIME& )
Constructs a CTime object from a FILETIME structure. You most likely will not use CTime FILETIME initialization directly. If you use a CFile object to manipulate a file, CFile::GetStatus retrieves the file time stamp for you via a CTime object initialized with a FILETIME structure.
Example
// example for CTime::CTime
time_t osBinaryTime
// C run-time time (defined in <time.h>)
osBinaryTime = WCE_FCTN(time) (NULL)
// Get the current time from // the operating system.
CTime time1
// Empty CTime. (0 is illegal time value.)
CTime time2 = time1
// Copy constructor.
CTime time3( osBinaryTime )
// CTime from C run-time time
CTime time4( 1999, 3, 19, 22, 15, 0 )
// 10:15PM March 19, 1999

Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afx.h
Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also
 
ctime=record

nYear:Shortint ;
nMonth:Shortint ;
nDay:Shortint ;
nHour:Shortint ;
nMin:Shortint ;
nSec:Shortint ;
nDST:Shortint ;
end;

CTime=record
wDosDate:word;
wDosTime:word;
nDST :byte;
end;

呵呵,问题依然没有解决啊!
 
tdate 到有,ttime 每有啊!
 
后退
顶部