orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
640 stars 38 forks source link

Insert current timestamp #279

Closed amay5267 closed 1 year ago

amay5267 commented 1 year ago

Hi @orbitalquark

Can you add new menu entry to Insert timestamp like this :

Wed Oct 12 15:15:00 2022

or any api or workaround for timestamp?

paaguti commented 1 year ago

I have keys['ctrl+D'] = function() return common.insert_date("%a, %d %b %Y %H:%m:%S %z") end and in my common module:

function M.today(spec) -- default timespec is year="%Y" month="%B" day="%d" -- like in RFCs local sysloc = os.setlocale(nil) os.setlocale("C") local now=os.date(spec or 'year="%Y" month="%B" day="%d"') os.setlocale(sysloc) return now end

function M.insert_date(spec) -- default timespec is "%A, %d %B %Y" -- insert_date() like in -- Last visit: ... comments in bibtex files view:replace_sel(M.today(spec or "%A, %d %B %Y")) return true -- don't do anything else end

It is so convoluted to deal with locales... could be simpler ;-)

On Thu, 13 Oct 2022 at 08:41, amay5267 @.***> wrote:

Hi @orbitalquark https://github.com/orbitalquark

Can you add new menu entry to Insert timestamp like this :

Wed Oct 12 15:15:00 2022

or any api or workaround for timestamp?

— Reply to this email directly, view it on GitHub https://github.com/orbitalquark/textadept/issues/279, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZKU4C26VSC2M7WSN6TWYLWC6VH3ANCNFSM6AAAAAARD6ETF4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler

Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet

amay5267 commented 1 year ago

Hi @paaguti

thanks. I am going to look into it a lil bit closer.

amay5267 commented 1 year ago

Any idea how to modify it and produce valid RFC 822? basicly i need that + 4 digit timezone number

orbitalquark commented 1 year ago

I don't know the finer details of how to print time, but putting this in your ~/.textadept/init.lua will add a menu item that inserts a timestamp at the current position in a buffer:

table.insert(textadept.menu.menubar[_L['Tools']], {
  'Insert Timestamp', function() buffer:add_text(-1, os.date()) end
})

Thu 13 Oct 2022 08:51:03 AM EDT