Home > Back-end >  C program design display date and time
C program design display date and time

Time:10-10

Hello, I am just learning c + + rookie, now to compile a program (date and time display), specific requirements are as follows, hope you glad, thank you very much!
Date/time according to
(1) to define a Time class Time, that you can provide, points, second of Time, method and provide the Time (in seconds),
(2) to define a Date Date, year, month, day, and provide the Date to increase method (in days),
(3) by the Time and Date class Date, derive a DateTime class, except with year, month, day,, points, SEC, also increase the name and Greenwich mean Time difference,
Make a application, enter the year, month, day,, points, SEC, analog display on the screen an electronic timer, under constant output for a second time and date, as well as the date and time of the Greenwich,
Note that 1 days later, when the date will be involved in the so-called "carry" problems: first, to calculate the "day" has a number of days in N, if after add 1 ", "numerical more than in the month with the number of days N," carry ", to the month and month if "carry" to even when more than 12 years,
Thinking: can add what you consider other functions, such as, to the input of date, calculate the interval of two date days, calculate a date for the week, print the object of current data from m y calendar, increase several days at a time, to other comparison operation of two dates,

CodePudding user response:

BCB in own TDateTime and TTime basic meet your requirements

CodePudding user response:

Using BCB own TDateTime components, with a date/time format function FormatDateTime (" mm - dd yyyy - hh: mm: ss ") processing into the format you need, if just need the current time use Now () function directly,
Such as:
1, do you want to display: the 2012-05-25 20:15:20
Can use the AnsiString sDateTime=FormatDateTime (" mm - dd yyyy - hh: mm: ss ", Now ());
2, do you want to display: May 25, 2012, 15 points in 20 seconds
Can use the AnsiString sDateTime=FormatDateTime (" on dd mm yyyy years hh mm ss second ", Now ());

CodePudding user response:

Thank you, still don't quite understand

CodePudding user response:

TDateTime for TDateTime data types and using TDateTime data type date-time run c + + class library routines,
TDateTime class continue to double val data members, which includes the date, time value, since 12/30/1899 TDateTime value of the integer part of the number of days, the fractional part for days,
The following for some examples of TDateTime values and the corresponding date and time:
Date and time values
0 12/30/1899 12:00 am
2.75/1/1 1900-6 PM
1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am
To calculate the decimal part of two days during the day, the two values is presupposed, and to increase in the decimal part one day in a date - the time value, can turn the decimal add date - the time value,

Methods list
CurrentDate returns the current date as a TDateTime value
CurrentDateTime returns the current date and time as a TDateTime value
CurrentTime returns the current time as a TDateTime value
DateString convert TDateTime value date to a string
DateTimeString convert TDateTime value to a string
DayOfWeek returns the TDateTime the day of the week
DecodeDate TDateTime value is divided into year, month, and day value and the value stored in the year, month and day parameters in
DecodeTime the TDateTime values into the hour, minute, second, and millisecond value and the value stored in the hour, min, SEC and msec parameter
FileDate convert date - the time value to DOS date-time tag
The FileDateToDateTime FileDate parameter specifies the DOS file date - time value into a TDateTime value
The format of the FormatString using the format given format TDateTime object
Operator - returns the difference between the two TDateTime sets new TDateTime object
Operator - returns a TDateTime Int parameter difference between with the new TDateTime object
The operator!=compare two TDateTime object identity not
Operator + returns a into two TDateTime object of a new TDateTime object
Operator +=TDateTime object itself data RHS joint is assigned to the specified TDateTime object TDateTime
Operator -=TDateTime object itself data RHS of the difference between the specified TDateTime object is assigned to TDateTime object
The operator & lt; Compare two TDateTime object
The operator & lt; Compare two TDateTime object=
The operator=RHS content is assigned to TDateTime
Compare two TDateTime object of the same operator==
The operator & gt; Compare two TDateTime object
The operator & gt; Compare two TDateTime object=
Operator AnsiString AnsiString for conversion operators
Operator double double for conversion operators
Operator int int for conversion operators
TDateTime TDateTime constructor
TimeString TDateTime object into AnsiString

Methods
TDateTime: : CurrentDate
Returns the current date as a TDateTime value,
The static TDateTime __fastcall CurrentDate ();
Retrieve the current date and return as new TDateTime object,

TDateTime: : CurrentDateTime
Returns the current date and time as a TDateTime value,
The static TDateTime __fastcall CurrentDateTime ();
Retrieve the current date and time and as new TDateTime object returns,

TDateTime: : CurrentTime
Returns the current time as a TDateTime value,
The static TDateTime __fastcall CurrentTime ();
Retrieve the current time and return as new TDateTime object,

TDateTime: : DateString
Convert TDateTime value date to a string,
AnsiString __fastcall DateString () const;
Return as a value of the AnsiString TDateTime object, conversion ShortDateFormat variable specifies the format of the,

TDateTime: : DateTimeString
Convert TDateTime value to a string,
Const AnsiString __fastcall DateTimeString ()
TDateTime object returns an AnsiString object, including the date and time data member (val) is converted to a string value, if the TDateTime value does not contain a date, the date is displayed for 00/00/00, if TDateTime value does not contain a time value, time is displayed as 00:00:00 AM, can change the date and time formats variable to change the string format,


TDateTime: : DayOfWeek
Returns the TDateTime the day of the week,
Const int __fastcall DayOfWeek ();
TDateTime DayOfWeek object into an integer between 1 to 7, Sunday is the first day of the week, Saturday is the seventh day,

TDateTime: : DecodeDate
The TDateTime values into the year, month and day value and the value stored in the year, month and day parameters,
Void __fastcall DecodeDate (unsigned short * year, unsigned short * month, unsigned short * day const;
Need to access the TDateTime object's year, month and day, using DecodeDate,

TDateTime: : DecodeTime
The TDateTime values into the hour, minute, second, and millisecond value and the values are stored in hour, min, SEC and msec parameters,
Void __fastcall DecodeTime (unsigned shot * and unsigned short * nim, unsigned short * the SEC, unsigned short * msec) const;
Need to access the TDateTime object of hour, minute, second, or millisecond, using DecodeDate,

TDateTime: : FileDate
Convert date - the time value to DOS date-time tag,
Const int __fastcall FileDate ();

TDateTime: : FileDateToDateTime
The fileDate parameter specifies the DOS file date - time value into a TDateTime value,
The static TDateTime __fastcall FileDateToDateTime (int fileDate);

TDateTime: : FormatString
Using the format given the format of the formatting TDateTime object,
AnsiString __fastcall FormatString (const AnsiString& The format);
Character string supports the following categories:

Classification character string displayed
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related