TIK (Modul Pascal) 7 Kelas XI Semester 3 Contoh lainnya adalah. Yang akan dibahas pada bab-bab selanjutnya Latihan Algoritma A. PILIHAN GANDA. Dua buah modul program, yaitu prosedur (PROCEDURE) dan fungsi (FUNCTION),.

  • Pascal Tutorial
  • Pascal Useful Resources
  • Selected Reading
PadaContoh Program Procedure Dan Function Pada Pascal

Most of the softwares you write need implementing some form of date functions returning current date and time. Dates are so much part of everyday life that it becomes easy to work with them without thinking. Pascal also provides powerful tools for date arithmetic that makes manipulating dates easy. However, the actual name and workings of these functions are different for different compilers.

Getting the Current Date & Time

Pascal's TimeToString function gives you the current time in a colon(: ) delimited form. The following example shows how to get the current time −

When the above code was compiled and executed, it produces the following result −

The Date function returns the current date in TDateTime format. The TDateTime is a double value, which needs some decoding and formatting. The following program demonstrates how to use it in your program to display the current date −

When the above code was compiled and executed, it produces the following result −

The Now function returns the current date and time −

When the above code was compiled and executed, it produces the following result −

Free Pascal provides a simple time stamp structure named TTimeStamp, which has the following format −

Various Date & Time Functions

Free Pascal provides the following date and time functions −

Sr.No.Function Name & Description
1

function DateTimeToFileDate(DateTime: TDateTime):LongInt;

Converts DateTime type to file date.

2

function DateTimeToStr( DateTime: TDateTime):;

Constructs string representation of DateTime

3

function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings):;

Constructs string representation of DateTime

4

procedure DateTimeToString(out Result: ;const FormatStr: ;const DateTime: TDateTime);

Constructs string representation of DateTime

5

procedure DateTimeToString(out Result: ; const FormatStr: ; const DateTime: TDateTime; const FormatSettings: TFormatSettings);

Constructs string representation of DateTime

6

procedure DateTimeToSystemTime(DateTime: TDateTime; out SystemTime: TSystemTime);

Converts DateTime to system time

7

function DateTimeToTimeStamp( DateTime: TDateTime):TTimeStamp;Converts DateTime to timestamp

8

function DateToStr(Date: TDateTime):;

Constructs string representation of date

9

function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings):;

Constructs string representation of date

10

function Date: TDateTime;

Gets current date

11

function DayOfWeek(DateTime: TDateTime):Integer;

Gets day of week

12

procedure DecodeDate(Date: TDateTime; out Year: Word; out Month: Word; out Day: Word);

Decodes DateTime to year month and day

13

procedure DecodeTime(Time: TDateTime; out Hour: Word; out Minute: Word; out Second: Word; out MilliSecond: Word);

Decodes DateTime to hours, minutes and seconds

14

function EncodeDate(Year: Word; Month: Word; Day: Word):TDateTime;

Encodes year, day and month to DateTime

15

function EncodeTime(Hour: Word; Minute: Word; Second: Word; MilliSecond: Word):TDateTime;

Encodes hours, minutes and seconds to DateTime

16

function FormatDateTime(const FormatStr: ; DateTime: TDateTime):;

Returns string representation of DateTime

17

function FormatDateTime(const FormatStr: ; DateTime: TDateTime; const FormatSettings: TFormatSettings):;

Returns string representation of DateTime

18

function IncMonth(const DateTime: TDateTime; NumberOfMonths: Integer = 1):TDateTime;

Adds 1 to month

19

function IsLeapYear(Year: Word):Boolean;

Determines if year is leap year

20

function MSecsToTimeStamp(MSecs: Comp):TTimeStamp;

Converts number of milliseconds to timestamp

21

function Now: TDateTime;

Gets current date and time

22

function StrToDateTime(const S:):TDateTime;

Converts string to DateTime

23

function StrToDateTime(const s: ShortString; const FormatSettings: TFormatSettings):TDateTime;

Converts string to DateTime

24

function StrToDateTime(const s: AnsiString; const FormatSettings: TFormatSettings):TDateTime;

Converts string to DateTime

25

function StrToDate(const S: ShortString):TDateTime;

Converts string to date

26

function StrToDate(const S: Ansistring):TDateTime;

Converts string to date

27

function StrToDate(const S: ShortString; separator: Char):TDateTime;

Converts string to date

28

function StrToDate(const S: AnsiString; separator: Char):TDateTime;

Serial key for wtm copy protection free. Converts string to date

29

function StrToDate(const S: ShortString; const useformat: ; separator: Char):TDateTime;

Converts string to date

30

function StrToDate(const S: AnsiString; const useformat: ; separator: Char):TDateTime;

Converts string to date

31

function StrToDate(const S: PChar; Len: Integer; const useformat: ; separator: Char = #0):TDateTime;

Converts string to date

32

function StrToTime(const S: Shortstring):TDateTime;

Converts string to time

33

function StrToTime(const S: Ansistring):TDateTime;

Converts string to time

34

function StrToTime(const S: ShortString; separator: Char):TDateTime;

Converts string to time

35

function StrToTime(const S: AnsiString; separator: Char):TDateTime;

Converts string to time

36

function StrToTime(const S: ; FormatSettings: TFormatSettings):TDateTime;

Converts string to time

37

function StrToTime(const S: PChar; Len: Integer; separator: Char = #0):TDateTime;

Converts string to time

38

function SystemTimeToDateTime(const SystemTime: TSystemTime):TDateTime;

Converts system time to datetime

39

function TimeStampToDateTime(const TimeStamp: TTimeStamp):TDateTime;

Converts time stamp to DateTime

40

function TimeStampToMSecs(const TimeStamp: TTimeStamp):comp;

Converts Timestamp to number of milliseconds

41

function TimeToStr(Time: TDateTime):;

Returns string representation of Time

42

function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings):;

Returns string representation of Time

43

function Time: TDateTime;

Get current time

The following example illustrates the use of some of the above functions −

When the above code was compiled and executed, it produced the following result:

Popular Posts

TIK (Modul Pascal) 7 Kelas XI Semester 3 Contoh lainnya adalah. Yang akan dibahas pada bab-bab selanjutnya Latihan Algoritma A. PILIHAN GANDA. Dua buah modul program, yaitu prosedur (PROCEDURE) dan fungsi (FUNCTION),.

  • Pascal Tutorial
  • Pascal Useful Resources
  • Selected Reading
\'Pada\'\'Contoh

Most of the softwares you write need implementing some form of date functions returning current date and time. Dates are so much part of everyday life that it becomes easy to work with them without thinking. Pascal also provides powerful tools for date arithmetic that makes manipulating dates easy. However, the actual name and workings of these functions are different for different compilers.

Getting the Current Date & Time

Pascal\'s TimeToString function gives you the current time in a colon(: ) delimited form. The following example shows how to get the current time −

When the above code was compiled and executed, it produces the following result −

The Date function returns the current date in TDateTime format. The TDateTime is a double value, which needs some decoding and formatting. The following program demonstrates how to use it in your program to display the current date −

When the above code was compiled and executed, it produces the following result −

The Now function returns the current date and time −

When the above code was compiled and executed, it produces the following result −

Free Pascal provides a simple time stamp structure named TTimeStamp, which has the following format −

Various Date & Time Functions

Free Pascal provides the following date and time functions −

Sr.No.Function Name & Description
1

function DateTimeToFileDate(DateTime: TDateTime):LongInt;

Converts DateTime type to file date.

2

function DateTimeToStr( DateTime: TDateTime):;

Constructs string representation of DateTime

3

function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings):;

Constructs string representation of DateTime

4

procedure DateTimeToString(out Result: ;const FormatStr: ;const DateTime: TDateTime);

Constructs string representation of DateTime

5

procedure DateTimeToString(out Result: ; const FormatStr: ; const DateTime: TDateTime; const FormatSettings: TFormatSettings);

Constructs string representation of DateTime

6

procedure DateTimeToSystemTime(DateTime: TDateTime; out SystemTime: TSystemTime);

Converts DateTime to system time

7

function DateTimeToTimeStamp( DateTime: TDateTime):TTimeStamp;Converts DateTime to timestamp

8

function DateToStr(Date: TDateTime):;

Constructs string representation of date

9

function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings):;

Constructs string representation of date

10

function Date: TDateTime;

Gets current date

11

function DayOfWeek(DateTime: TDateTime):Integer;

Gets day of week

12

procedure DecodeDate(Date: TDateTime; out Year: Word; out Month: Word; out Day: Word);

Decodes DateTime to year month and day

13

procedure DecodeTime(Time: TDateTime; out Hour: Word; out Minute: Word; out Second: Word; out MilliSecond: Word);

Decodes DateTime to hours, minutes and seconds

14

function EncodeDate(Year: Word; Month: Word; Day: Word):TDateTime;

Encodes year, day and month to DateTime

15

function EncodeTime(Hour: Word; Minute: Word; Second: Word; MilliSecond: Word):TDateTime;

Encodes hours, minutes and seconds to DateTime

16

function FormatDateTime(const FormatStr: ; DateTime: TDateTime):;

Returns string representation of DateTime

17

function FormatDateTime(const FormatStr: ; DateTime: TDateTime; const FormatSettings: TFormatSettings):;

Returns string representation of DateTime

18

function IncMonth(const DateTime: TDateTime; NumberOfMonths: Integer = 1):TDateTime;

Adds 1 to month

19

function IsLeapYear(Year: Word):Boolean;

Determines if year is leap year

20

function MSecsToTimeStamp(MSecs: Comp):TTimeStamp;

Converts number of milliseconds to timestamp

21

function Now: TDateTime;

Gets current date and time

22

function StrToDateTime(const S:):TDateTime;

Converts string to DateTime

23

function StrToDateTime(const s: ShortString; const FormatSettings: TFormatSettings):TDateTime;

Converts string to DateTime

24

function StrToDateTime(const s: AnsiString; const FormatSettings: TFormatSettings):TDateTime;

Converts string to DateTime

25

function StrToDate(const S: ShortString):TDateTime;

Converts string to date

26

function StrToDate(const S: Ansistring):TDateTime;

Converts string to date

27

function StrToDate(const S: ShortString; separator: Char):TDateTime;

Converts string to date

28

function StrToDate(const S: AnsiString; separator: Char):TDateTime;

Serial key for wtm copy protection free. Converts string to date

29

function StrToDate(const S: ShortString; const useformat: ; separator: Char):TDateTime;

Converts string to date

30

function StrToDate(const S: AnsiString; const useformat: ; separator: Char):TDateTime;

Converts string to date

31

function StrToDate(const S: PChar; Len: Integer; const useformat: ; separator: Char = #0):TDateTime;

Converts string to date

32

function StrToTime(const S: Shortstring):TDateTime;

Converts string to time

33

function StrToTime(const S: Ansistring):TDateTime;

Converts string to time

34

function StrToTime(const S: ShortString; separator: Char):TDateTime;

Converts string to time

35

function StrToTime(const S: AnsiString; separator: Char):TDateTime;

Converts string to time

36

function StrToTime(const S: ; FormatSettings: TFormatSettings):TDateTime;

Converts string to time

37

function StrToTime(const S: PChar; Len: Integer; separator: Char = #0):TDateTime;

Converts string to time

38

function SystemTimeToDateTime(const SystemTime: TSystemTime):TDateTime;

Converts system time to datetime

39

function TimeStampToDateTime(const TimeStamp: TTimeStamp):TDateTime;

Converts time stamp to DateTime

40

function TimeStampToMSecs(const TimeStamp: TTimeStamp):comp;

Converts Timestamp to number of milliseconds

41

function TimeToStr(Time: TDateTime):;

Returns string representation of Time

42

function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings):;

Returns string representation of Time

43

function Time: TDateTime;

Get current time

The following example illustrates the use of some of the above functions −

When the above code was compiled and executed, it produced the following result:

...'>Contoh Program Procedure Dan Function Pada Pascal(13.03.2020)
  • laserqplus.netlify.com〓 Contoh Program Procedure Dan Function Pada Pascal
  • TIK (Modul Pascal) 7 Kelas XI Semester 3 Contoh lainnya adalah. Yang akan dibahas pada bab-bab selanjutnya Latihan Algoritma A. PILIHAN GANDA. Dua buah modul program, yaitu prosedur (PROCEDURE) dan fungsi (FUNCTION),.

    • Pascal Tutorial
    • Pascal Useful Resources
    • Selected Reading
    \'Pada\'\'Contoh

    Most of the softwares you write need implementing some form of date functions returning current date and time. Dates are so much part of everyday life that it becomes easy to work with them without thinking. Pascal also provides powerful tools for date arithmetic that makes manipulating dates easy. However, the actual name and workings of these functions are different for different compilers.

    Getting the Current Date & Time

    Pascal\'s TimeToString function gives you the current time in a colon(: ) delimited form. The following example shows how to get the current time −

    When the above code was compiled and executed, it produces the following result −

    The Date function returns the current date in TDateTime format. The TDateTime is a double value, which needs some decoding and formatting. The following program demonstrates how to use it in your program to display the current date −

    When the above code was compiled and executed, it produces the following result −

    The Now function returns the current date and time −

    When the above code was compiled and executed, it produces the following result −

    Free Pascal provides a simple time stamp structure named TTimeStamp, which has the following format −

    Various Date & Time Functions

    Free Pascal provides the following date and time functions −

    Sr.No.Function Name & Description
    1

    function DateTimeToFileDate(DateTime: TDateTime):LongInt;

    Converts DateTime type to file date.

    2

    function DateTimeToStr( DateTime: TDateTime):;

    Constructs string representation of DateTime

    3

    function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings):;

    Constructs string representation of DateTime

    4

    procedure DateTimeToString(out Result: ;const FormatStr: ;const DateTime: TDateTime);

    Constructs string representation of DateTime

    5

    procedure DateTimeToString(out Result: ; const FormatStr: ; const DateTime: TDateTime; const FormatSettings: TFormatSettings);

    Constructs string representation of DateTime

    6

    procedure DateTimeToSystemTime(DateTime: TDateTime; out SystemTime: TSystemTime);

    Converts DateTime to system time

    7

    function DateTimeToTimeStamp( DateTime: TDateTime):TTimeStamp;Converts DateTime to timestamp

    8

    function DateToStr(Date: TDateTime):;

    Constructs string representation of date

    9

    function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings):;

    Constructs string representation of date

    10

    function Date: TDateTime;

    Gets current date

    11

    function DayOfWeek(DateTime: TDateTime):Integer;

    Gets day of week

    12

    procedure DecodeDate(Date: TDateTime; out Year: Word; out Month: Word; out Day: Word);

    Decodes DateTime to year month and day

    13

    procedure DecodeTime(Time: TDateTime; out Hour: Word; out Minute: Word; out Second: Word; out MilliSecond: Word);

    Decodes DateTime to hours, minutes and seconds

    14

    function EncodeDate(Year: Word; Month: Word; Day: Word):TDateTime;

    Encodes year, day and month to DateTime

    15

    function EncodeTime(Hour: Word; Minute: Word; Second: Word; MilliSecond: Word):TDateTime;

    Encodes hours, minutes and seconds to DateTime

    16

    function FormatDateTime(const FormatStr: ; DateTime: TDateTime):;

    Returns string representation of DateTime

    17

    function FormatDateTime(const FormatStr: ; DateTime: TDateTime; const FormatSettings: TFormatSettings):;

    Returns string representation of DateTime

    18

    function IncMonth(const DateTime: TDateTime; NumberOfMonths: Integer = 1):TDateTime;

    Adds 1 to month

    19

    function IsLeapYear(Year: Word):Boolean;

    Determines if year is leap year

    20

    function MSecsToTimeStamp(MSecs: Comp):TTimeStamp;

    Converts number of milliseconds to timestamp

    21

    function Now: TDateTime;

    Gets current date and time

    22

    function StrToDateTime(const S:):TDateTime;

    Converts string to DateTime

    23

    function StrToDateTime(const s: ShortString; const FormatSettings: TFormatSettings):TDateTime;

    Converts string to DateTime

    24

    function StrToDateTime(const s: AnsiString; const FormatSettings: TFormatSettings):TDateTime;

    Converts string to DateTime

    25

    function StrToDate(const S: ShortString):TDateTime;

    Converts string to date

    26

    function StrToDate(const S: Ansistring):TDateTime;

    Converts string to date

    27

    function StrToDate(const S: ShortString; separator: Char):TDateTime;

    Converts string to date

    28

    function StrToDate(const S: AnsiString; separator: Char):TDateTime;

    Serial key for wtm copy protection free. Converts string to date

    29

    function StrToDate(const S: ShortString; const useformat: ; separator: Char):TDateTime;

    Converts string to date

    30

    function StrToDate(const S: AnsiString; const useformat: ; separator: Char):TDateTime;

    Converts string to date

    31

    function StrToDate(const S: PChar; Len: Integer; const useformat: ; separator: Char = #0):TDateTime;

    Converts string to date

    32

    function StrToTime(const S: Shortstring):TDateTime;

    Converts string to time

    33

    function StrToTime(const S: Ansistring):TDateTime;

    Converts string to time

    34

    function StrToTime(const S: ShortString; separator: Char):TDateTime;

    Converts string to time

    35

    function StrToTime(const S: AnsiString; separator: Char):TDateTime;

    Converts string to time

    36

    function StrToTime(const S: ; FormatSettings: TFormatSettings):TDateTime;

    Converts string to time

    37

    function StrToTime(const S: PChar; Len: Integer; separator: Char = #0):TDateTime;

    Converts string to time

    38

    function SystemTimeToDateTime(const SystemTime: TSystemTime):TDateTime;

    Converts system time to datetime

    39

    function TimeStampToDateTime(const TimeStamp: TTimeStamp):TDateTime;

    Converts time stamp to DateTime

    40

    function TimeStampToMSecs(const TimeStamp: TTimeStamp):comp;

    Converts Timestamp to number of milliseconds

    41

    function TimeToStr(Time: TDateTime):;

    Returns string representation of Time

    42

    function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings):;

    Returns string representation of Time

    43

    function Time: TDateTime;

    Get current time

    The following example illustrates the use of some of the above functions −

    When the above code was compiled and executed, it produced the following result:

    ...'>Contoh Program Procedure Dan Function Pada Pascal(13.03.2020)