Easy-to-understand-function that returns the day todays name in string and takes no parameters. It returns the name in Englsih even if the operating system is another laguage. Good for text editing programs. Please rate...
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Here is an example of what the function returns:
'The day today is ' + daytoday+'.'
Returns on a monday:
The day today is Monday.
Here is the function:
function daytoday: string;
begin
Result:=''; {Can be removed}
if dayofweek(now)=1 then
result:='Sunday' else
if dayofweek(now)=2 then
result:='Monday' else
if dayofweek(now)=3 then
result:='Tuesday' else
if dayofweek(now)=4 then
result:='Wednesday' else
if dayofweek(now)=5 then
result:='Thursday' else
if dayofweek(now)=6 then
result:='Friday' else
if dayofweek(now)=7 then
result:='Saturday';
end;
I understand that this code for beginners. You can use case insted of "if" statment...it faster. But did you ever think about that this function read computer date/time ... what if computer time settings incorrect? It is a subject to think about. (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)