Print Page | Close Window

How can I print the actual date ?

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=769
Printed Date: 27.Mar.2026 at 03:35
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: How can I print the actual date ?
Posted By: JulioFilho
Subject: How can I print the actual date ?
Date Posted: 11.Mar.2014 at 14:09
Hi guys,

I want to include a comment line in my code with the date and time of the generation.  How can I do that?

Thanks in advance,

Julio



Replies:
Posted By: stevek
Date Posted: 11.Mar.2014 at 15:03
Date and time calculation and formatting is something we've deliberately left out of MERL, so you can just use whatever date and time library or OS function you're already familiar with. E.g. to grab the current date and time from DOS into a variable in MERL:
 
$dateTimeFile = 'datetime.txt'
external 'cmd /x /c echo %date% %time% >' $dateTimeFile executeBlocking
$dateTime = __(filename $dateTimeFile read)
 
There are probably good reasons in your case why you want to do this. In general, I wouldn't recommend including timestamps in source code - it means that every generation gives a different result, even though the real source, the model, hasn't changed. It also changes what the compiler sees as the source, so it will have to recompile every file every time; if you don't add the timestamp, MetaEdit+ automatically notices when the generated file is the same as what is already on disk, and doesn't overwrite it, which allows most compilers to avoid recompiling that file.


Posted By: JulioFilho
Date Posted: 13.Mar.2014 at 12:11
Many thanks for the quick answer.

Well, I am doing that for documentation purposes in a file that does not affect compiler or things in the sort.  I do need that because I want to keep track of when the code (documentation) was generated.

Though I do not agree that it is not desirable to have that in MERL, I think your answer will do the trick for the moment.

Thanks again,

Julio




Posted By: stevek
Date Posted: 08.Apr.2019 at 12:21
In 5.5 and later, the code can be simpler (and significantly faster) with http://www.metacase.com/support/55/manuals/mwb/Mw-6_4_7.html#Heading2093" rel="nofollow - external...read :
 
external 'echo %date% %time%' read

This will be in your current locale format. 
For other date formats, see  http://stackoverflow.com/a/19799236/1166064" rel="nofollow - https://stackoverflow.com/a/19799236/1166064 .



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net