Author Topic: How to modify paste-format of "Edit >> Insert Date/Time"  (Read 2462 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
How to modify paste-format of "Edit >> Insert Date/Time"
« on: March 07, 2009, 08:51:51 PM »
As default you will find in menu "Edit >> Insert Date/Time"
the follow formats to insert into your document:

    07.03.2009 19:54
    07.03.09 07:55 PM
    03/07/09 19:55:14
    Saturday, March 07, 2009 19:55:27
    Saturday, March 07, 2009
(see No. (1)  at  picture below)


This format are set in file "def_spec.xml"   in your syntax folder.
(see No. (2)  at  picture below)


This format can be modified and/or you can add more formats you like.
You can add as much entries in InsertDateTime entry as you like, with any format.
See >MSDN link< for list of supported vars.  

I list this vars here if the link is broken some time:
Code: [Select]
  http://msdn.microsoft.com/en-us/library/fe06s4ak.aspx

     The formatting codes for strftime are listed below:

    %a        Abbreviated weekday name
    %A        Full weekday name
    %b        Abbreviated month name
    %B        Full month name
    %c        Date and time representation appropriate for locale
    %d        Day of month as decimal number (01 – 31)
    %H        Hour in 24-hour format (00 – 23)
    %I        Hour in 12-hour format (01 – 12)
    %j        Day of year as decimal number (001 – 366)
    %m        Month as decimal number (01 – 12)
    %M        Minute as decimal number (00 – 59)
    %p        Current locale's A.M./P.M. indicator for 12-hour clock
    %S        Second as decimal number (00 – 59)
    %U        Week of year as decimal number, with Sunday as first day of week (00 – 53)
    %w        Weekday as decimal number (0 – 6; Sunday is 0)
    %W        Week of year as decimal number, with Monday as first day of week (00 – 53)
    %x        Date representation for current locale
    %X        Time representation for current locale
    %y        Year without century, as decimal number (00 – 99)
    %Y        Year with century, as decimal number
    %z, %Z        Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
    %%        Percent sign



     As in the printf function, the # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows.

    Format code                                      ---- Meaning

    %#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z, %#%     ----  # flag is ignored.
    %#c                                ----- Long date and time representation, appropriate for current locale.
                                       -- For example: "Tuesday, March 14, 1995, 12:41:29".
    %#x                             -----    Long date representation, appropriate to current locale.
                                       -- For example: "Tuesday, March 14, 1995".
    %#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y  ---- Remove leading zeros (if any).


So if you want f.ex. to get NO leading zero just add an # -sign to the vars.
(see No. (3)  at  picture below)

Here is an example:
<Insert format="%#d.%#m.%Y %#H:%M"/>  
<Insert format="%#d.%#m.%y %#I:%M %p"/>

this will get  you formats like:
7.3.2009   20:11
7.3.09   8:11 PM


---

Here is an overview of default and our customized items:
<InsertDateTime>
      <Insert format="%d.%m.%Y %H:%M"/>           07.03.2009 19:54
      <Insert format="%d.%m.%y %I:%M %p"/>        07.03.09 07:55 PM
      <Insert format="%c"/>                       03/07/09 19:55:14
      <Insert format="%#c"/>                      Saturday, March 07,2009 19:55:27
      <Insert format="%#x"/>                      Saturday, March 07, 2009
     <Insert format="%#d.%#m.%Y %#H:%M"/>        7.3.2009 20:11
      <Insert format="%#d.%#m.%y %#I:%M %p"/>     7.3.09 8:11 PM

</InsertDateTime>

--

You may even try this:
<Insert format="%d.%m.%Y, um %H:%M Uhr"/>
<Insert format="Notiz von %H:%M, am %d.%m.%Y"/>
<Insert format="Downloaded at %Y.%m.%d"/>

to get:
07.03.2009, um 21:14 Uhr
Notiz von 21:14, am 07.03.2009
Downloaded at 2009.03.07

--

Just modify your def_spec.xml and add the formats you want.
Note:  you have to restart HippoEDIT to get the new items.

----------------


I just had the need for this time formate , for an kind of daily log:

 <Insert format="%Y.%m.%d %H:%M - %A"/>   ==>  2009.11.06 13:22 - Freitag

---

To assign an shortcut to insert this by an key-press:

- "Edit > Insert Date/Time>"
- remember the location of the format you want to insert, for example the fourth from top
- "Tools > Keyboard Settings..."
- In Commands start typing 'ins' to see all entries containing 'insert' as f.ex. 'Edit.InsertDateTime1'
- select the entry you have remembered from "Edit > Insert Date/Time>" preview,
   here f.ex. the fourth one ==> 'Edit.InsertDateTime4'
- then select the "New Shortcut" -field and press an key combination, f.ex. 'Ctrl+Alt+D'
- [Assign]
- If all went fine, close the "Keyboard Settings..." -dialog
- try it

----------------


--- see the picture:
« Last Edit: November 06, 2009, 01:41:40 PM by Stefan »
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-