<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TextFX - customizing the date&#x2F;time format]]></title><description><![CDATA[<p dir="auto">This is a continuation of the <a href="https://notepad-plus-plus.org/community/topic/17730/textfx-insert-questions" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/17730/textfx-insert-questions</a> thread which has topic-drifted into that TextFX itself is no longer supported.</p>
<p dir="auto">The goal is to learn how to set up substitutes. using Pythonscript, for TextFX’s Insert date &amp; time functions and to set up keyboard shortcuts.  For example, at present I have F5 mapped to TextFX’s Insert date &amp; time - short format which generates “4:43 PM 5/30/2019.”  My desire is for that F5 generate the date &amp; time formatted as 05/30/2019 16:43. Once that’s available I’ll set up another keyboard shortcut to generate a yyyy-mm-dd hh:mm format (and probably add the :ss seconds too as I can backspace those out if I don’t need them)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/17738/textfx-customizing-the-date-time-format</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 13:13:39 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/17738.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 31 May 2019 22:51:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TextFX - customizing the date&#x2F;time format on Mon, 03 Jun 2019 13:27:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said:</p>
<blockquote>
<p dir="auto">And you accuse me of addiction to the forum? :-)</p>
</blockquote>
<p dir="auto">Yea, I TOTALLY KNEW that was coming!</p>
<p dir="auto">So oftentimes a forum posting pushes one into doing something that was already on the TODO list, or something on the even-more-populated started-but-never-finished list.</p>
<h1>:)</h1>
]]></description><link>https://community.notepad-plus-plus.org/post/44153</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/44153</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 03 Jun 2019 13:27:42 GMT</pubDate></item><item><title><![CDATA[Reply to TextFX - customizing the date&#x2F;time format on Mon, 03 Jun 2019 13:17:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> Do not quarrel boys)))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/44152</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/44152</guid><dc:creator><![CDATA[andrecool-68]]></dc:creator><pubDate>Mon, 03 Jun 2019 13:17:04 GMT</pubDate></item><item><title><![CDATA[Reply to TextFX - customizing the date&#x2F;time format on Mon, 03 Jun 2019 13:14:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said:</p>
<blockquote>
<p dir="auto">So even though I didn’t get feedback from the OP yet, I came up with a little Pythonscript for this</p>
</blockquote>
<p dir="auto">And you <a href="https://notepad-plus-plus.org/community/topic/17744/count-the-occurences-of-each-line/10" rel="nofollow ugc">accuse <em>me</em></a> of addiction to the forum? :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/44151</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/44151</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 03 Jun 2019 13:14:10 GMT</pubDate></item><item><title><![CDATA[Reply to TextFX - customizing the date&#x2F;time format on Mon, 03 Jun 2019 01:22:03 GMT]]></title><description><![CDATA[<p dir="auto">So even though I didn’t get feedback from the OP yet, I came up with a little Pythonscript for this; stole the input mechanism from something I already had.  Basically, you define the formats you want to use in the source code (I’ve predefined some) and then when the script is run, it shows you different examples of the current time formatted in different ways.</p>
<p dir="auto">Here’s what it looks like at runtime:</p>
<p dir="auto"><img src="https://i.imgur.com/MXooVwS.png" alt="Imgur" class=" img-fluid img-markdown" /></p>
<p dir="auto">If there are more than 5 choices defined (I defined 6), then if what you are looking for doesn’t appear on-screen you simply enter <code>&gt;</code> and click OK and the next group of choices is displayed.  When you see the format you want to insert, just enter its letter, e.g. <code>c</code> (overwriting ALL of the preselected blue text) and click OK.  At that point the desired timestamp text will be inserted into the currently active Notepad++ file.</p>
<p dir="auto">Here’s the Pythonscript that does this:</p>
<pre><code class="language-z">import time

time_formats_list = [
    "%I:%M %p %m/%d/%Y",     #  08:56 PM 06/02/2019
    "%I:%M:%S %p %m/%d/%Y",  #  08:56:15 PM 06/02/2019
    "%b %d %Y %H:%M:%S",     #  Jun 02 2019 20:56:15
    "%m/%d/%Y %H:%M:%S",     #  06/02/2019 20:56:15
    "%m/%d/%Y %H:%M",        #  06/02/2019 20:56
    "%A %b %d %Y %H:%M:%S",  #  Sunday Jun 02 2019 20:56:15
]

# for format codes, see https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
'''
%a - Weekday as locale's abbreviated name. Sun, Mon, ..., Sat (en_US); So, Mo, ..., Sa (de_DE)
%A - Weekday as locale's full name. Sunday, Monday, ..., Saturday (en_US); Sonntag, Montag, ..., Samstag (de_DE)
%w - Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. 0, 1, ..., 6
%d - Day of the month as a zero-padded decimal number. 01, 02, ..., 31
%b - Month as locale's abbreviated name. Jan, Feb, ..., Dec (en_US); Jan, Feb, ..., Dez (de_DE)
%B - Month as locale's full name. January, February, ..., December (en_US); Januar, Februar, ..., Dezember (de_DE)
%m - Month as a zero-padded decimal number. 01, 02, ..., 12
%y - Year without century as a zero-padded decimal number. 00, 01, ..., 99
%Y - Year with century as a decimal number. 1970, 1988, 2001, 2013
%H - Hour (24-hour clock) as a zero-padded decimal number. 00, 01, ..., 23
%I - Hour (12-hour clock) as a zero-padded decimal number. 01, 02, ..., 12
%p - Locale's equivalent of either AM or PM. AM, PM (en_US); am, pm (de_DE)
%M - Minute as a zero-padded decimal number. 00, 01, ..., 59
%S - Second as a zero-padded decimal number. 00, 01, ..., 59
%f - Microsecond as a decimal number, zero-padded on the left. 000000, 000001, ..., 999999
%z - UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). (empty), +0000, -0400, +1030
%Z - Time zone name (empty string if the object is naive). (empty), UTC, EST, CST
%j - Day of the year as a zero-padded decimal number. 001, 002, ..., 366
%U - Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. 00, 01, ..., 53
%W - Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. 00, 01, ..., 53
%c - Locale's appropriate date and time representation. Tue Aug 16 21:30:00 1988 (en_US); Di 16 Aug 21:30:00 1988 (de_DE)
%x - Locale's appropriate date representation. 08/16/88 (None); 08/16/1988 (en_US); 16.08.1988 (de_DE)
%X - Locale's appropriate time representation. 21:30:00 (en_US); 21:30:00 (de_DE)
%% - A literal '%' character. %
'''

instructions0 = "\r\nEnter letter of your choice"
instructions1 = instructions0 + " or &gt; for next group"
instructions2 = instructions0 + " or &gt;(next group) or &lt;(previous group)"
instructions3 = instructions0 + " or &lt; for previous group"

max_choices_fit_1_screen = 5

prompt_number_start = 0

while True:

    prompt_number_end = prompt_number_start + max_choices_fit_1_screen
    if prompt_number_end &gt; prompt_number_start + len(time_formats_list):
        prompt_number_end = prompt_number_start + len(time_formats_list)

    prompt_body = ''
    for (j, v) in enumerate(time_formats_list[prompt_number_start : prompt_number_end + 1]):
        letter_choice = chr(ord('a') + prompt_number_start + j)
        example = time.strftime(v, time.localtime())
        prompt_body += ' {})     {}'.format(letter_choice, example)       # leading space is important!
        if prompt_number_start + j != len(time_formats_list) - 1: prompt_body += "\r\n"

    if prompt_number_start == 0:
        if len(time_formats_list) &gt; max_choices_fit_1_screen:
            instructions = instructions1
        else:
            instructions = instructions0
    else:
        if prompt_number_end == len(time_formats_list):
            instructions = instructions3
        else:
            instructions = instructions2

    prompt_result = notepad.prompt(instructions, "Timestamp Insert (at caret)", prompt_body)

    if prompt_result == None: break  # user cancelled the dialog box

    if prompt_result == '&lt;' or prompt_result == ',':
        # show previous group
        prompt_number_start -= max_choices_fit_1_screen
        if prompt_number_start &lt; 0: prompt_number_start = 0
        continue

    if prompt_result == '&gt;' or prompt_result == '.':
        # show next group
        prompt_number_start += max_choices_fit_1_screen
        if prompt_number_start + max_choices_fit_1_screen &gt; len(time_formats_list):
            prompt_number_start = len(time_formats_list) - max_choices_fit_1_screen
            if prompt_number_start &lt; 0: prompt_number_start = 0
        continue

    if len(prompt_result) &gt; 0:
        user_choice_letter = prompt_result[0].lower()
        temp = ord(user_choice_letter) - ord('a')
        if temp &gt;= 0 and temp &lt; len(time_formats_list):
            text = time.strftime(time_formats_list[temp], time.localtime())
            curr_pos = editor.getCurrentPos()
            editor.insertText(curr_pos, text)
            editor.setEmptySelection(curr_pos + len(text))
            break
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/44128</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/44128</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 03 Jun 2019 01:22:03 GMT</pubDate></item><item><title><![CDATA[Reply to TextFX - customizing the date&#x2F;time format on Sat, 01 Jun 2019 02:11:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mkupper" aria-label="Profile: mkupper">@<bdi>mkupper</bdi></a></p>
<p dir="auto">It might best best to have a dialog box come up and allow you to select which format you want from a list?  The list would be in the format of examples of the current time, each formatted differently.  If you like that idea, we can proceed with that.  An upside of this is that there need only be one script.  Selecting a format and choosing OK would insert the time in the chosen format into the current document.  The downside of this is that it is hard to have a “long” list of formats in the dialog box that Pythonscript provides.  I do have a workaround for that, though.</p>
<p dir="auto">Otherwise, with Pythonscripts, it is a one script per keycombination kind of thing.  Thus, if you want 3 different hotkeys to insert 3 different timestamp formats, you have to have 3 script files that are 90% the same repeated code.  It’s okay…but not ideal.  I think Luascript is better in this regard, but I’m not sure as I don’t know much about Lua or the Luascript plugin.</p>
<p dir="auto">So we will take some ideas from these links to build your final scripts:</p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/16147/date-and-time" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/16147/date-and-time</a><br />
<a href="https://notepad-plus-plus.org/community/topic/13792/date-time-again" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13792/date-time-again</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/44069</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/44069</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 01 Jun 2019 02:11:48 GMT</pubDate></item></channel></rss>