Pascal - Functions





❤️ Click here: Free pascal date time functions


In case of non-alphabetic character, it returns the same character. Calculate the number of whole months between two DateTime values Calculate the approximate number of months between two DateTime values.


ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. Return the number of days in the month in which a date occurs. Pascal also provides powerful tools for date arithmetic that makes manipulating dates easy.


Pascal - Date and Time - However, the actual name and workings of these functions are different for different compilers.


ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the. A common prefix Wide in the function name indicates that the function deals with strings WideString. ReNamer has similar functions without Wide prefix, for processing ANSI strings. For example, ShowMessage and WideShowMessage procedures. Length Management Routine Remarks procedure SetLength var S: Array; NewLength: Integer ; Sets the length of array variable S to NewLength. Unicode String Handling Routine Remarks procedure WideInsert const Substr: WideString; var Dest: WideString; Index: Integer ; Inserts Substr in Dest at position Index. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything. Returns the position of first occurrence, or 0 if nothing was found. Returns the position of first occurrence, or 0 if nothing was found. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2. Returns TRUE if both are identical, otherwise returns FALSE. Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase. First letter of every word is capitalized. All other alphabetic characters are converted to lowercase. Meta Tags Extraction Function Remarks function CalculateMetaTag const FilePath: WideString; const MetaTagName: String : WideString; Extracts and returns the value of a meta tag specified by MetaTagName from the file specified by the complete absolute path FilePath. Return type changed from String to WideString in v5. The full list of meta tags can be found in article. Regular Expressions Function Remarks function IsMatchingRegEx const Input, Pattern: WideString; const CaseSensitive: Boolean : Boolean; Check for a match against a RegEx pattern. Function returns an array of full matches, which matched the entire expression, not the sub-patterns. Unicode Character Handling Function Remarks function IsWideCharUpper WC: WideChar : Boolean; Checks a Unicode character WC and returns TRUE if it is in UPPERCASE. In case of non-alphabetic character, it returns the same character. In case of non-alphabetic character, it returns the same character. More information regarding classification can be found on the internet. Unicode Conversion Function Remarks function WideToAnsi const WS: WideString : String; Converts a string to its version. Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file. Console Output Conversion OEM-defined character set is commonly used in the output of console applications. Function Remarks function OemToAnsi const S: String : String; Convert OEM string into an ANSI string. Basic Conversion Function Remarks function BoolToStr B: Boolean : String; Convert boolean variable into a string. You can use FormatFloat function to convert Int64 values to a string without a loss of range. Returns False if conversion operation has failed. Warning: An error will occur if the parameter to this function cannot be converted to a floating point value! Check below for more information. Warning: An error will occur if the parameter to this function cannot be converted to an integer! Floating point format specifiers Specifier Represents 0 zero Digit placeholder. Otherwise, nothing is stored in that position in the output string. Date and Time Function Remarks function Date: TDateTime; Returns the current system date. An error will be raised if parameters are invalid. An error will be raised if parameters are invalid. Similar to EncodeDate and EncodeTime. If operation was successful, function will return TRUE and the generated date value will be written in the Date variable. If operation was successful, function will return TRUE and the generated time value will be written in the Time variable. If operation was successful, function will return TRUE and the generated date-time value will be written in the ADateTime variable. File Management Function Remarks function WideFileSize const FileName: WideString : Int64; Returns the size of the file in bytes. The return value is of type Int64 which can store the maximum file size of 9,223,372,036,854,775,807 bytes. Returns TRUE if file exists, otherwise FALSE. Returns TRUE if directory exists, otherwise FALSE. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created. Returns TRUE on success, otherwise FALSE. Returns TRUE on success, otherwise FALSE. Returns TRUE on success, otherwise FALSE. Returns TRUE on success, otherwise FALSE. Note: You must provide a full path to delete the file to the Recycle Bin a quirk of Windows API. Returns TRUE on success, otherwise FALSE. If FailIfExists flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string. This function does not verify that the resulting path refers to an existing file. Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files. Return TRUE if matches, otherwise FALSE. Return TRUE if matches, otherwise FALSE. Start is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 zero. LineNum is 1 based, so to get the first line set this parameter to 1 one. Note: This function is extremely inefficient and provided only for convenience! Note: This function is extremely inefficient and provided only for convenience! If target file already exists, it will be overwritten. If target file does not exist, it will be created. Note: Automatic text encoding handling is based on BOM and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding. File Time Function Remarks function FileTimeModified const FileName: WideString : TDateTime; Returns last modified time of the specified file. Process Execution Function Remarks function ShellOpenFile const FileName: WideString : Boolean; Run open a file specified by FileName. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. Parameter WaitForProgram allows you to specify whether the code needs to wait until the command launched program has finished executing. WaitForProgram parameter allows you to specify whether the code needs to wait until the command launched program has finished executing. ShowWindowFlag parameter controls how the window is to be shown. This function should be used only for console style applications. Returns the exit code. Console application output uses OEM-defined character set by default, unless application itself changes its output code page. OemToAnsi and OemToWide functions can be used to convert OEM output. Dialogs Function Remarks procedure ShowMessage const Msg: String ; Show a simple dialog with the message specified by Msg parameter. Returns TRUE if user clicks Yes button, otherwise FALSE. It asks the user to enter data in a text box on the dialog. A ADefault value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise ADefault value is returned. The default value and the value of the text box after the dialog is closed are transferred via the Value parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE. Index ranges from 1 to GetTotalNumberOfFiles. Index ranges from 1 to GetTotalNumberOfMarkedFiles. System Function Remarks function WideGetCurrentDir: WideString; Returns the current working directory. If returned value is empty it means that temporary folder could not be determined. Miscellaneous Function Remarks procedure Sleep Milliseconds: Cardinal ; Sleep pause the execution for specified number of Milliseconds. Dividend is the integer into which you are dividing. Divisor is the value by which to divide Dividend. Result returns the result of the integer division. Note: Should only be called once per application cycle, at the start of the process! Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet. All occurrences of %XX hex format are decoded, then entire string is decoded from UTF8. UsePlusAsSpace parameter added in v6. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in %XX hex format. The precision of this timer is very limited. Pass a type identifier to determine the number of bytes used to represent instances of that type.


Calculating Date and Time Differences in Excel
Calculate the number of hours passed since the start of the year. But dates from the 1st of a month to the 1st of the next month should be considered to span a full month, shouldn't it. Print whether a date is free pascal date time functions a leap year. The following example shows how to get the current time: program TimeDemo ; uses sysutils ; begin writeln 'Current time : 'TimeToStr Time ; end. Better should be: DecodeDate Date1, Y0,M0,D0 ; DecodeDate Date2,Y,M,D ; dec Y,Y0 ; dec M,M0 ; dec D,D0 ; with the glad effect that now M and D can become negative and have to be adjusted again. Raise an EConvertError exception when a day is not a valid day of a year. Do an EncodeDate and you're all set. Replace selected parts of a TDateTime value with other custodes Convert UTC time to local time Convert Unix Timestamp to a Mac Timestamp Convert Unix epoch time to a TDateTime value Extract week of the year from a given date.