Adding timestamps in a spreadsheet?


HelenF

Very Active Member
Joined
Jun 22, 2013
Messages
615
Location
UK
Gnumeric can insert the current date, time to the minute, or datetime to the minute. LibreOffice Calc can insert the date, or time to hundredths of a second. I'd like to use a keyboard shortcut to put datetime to the second in the current cell. I guess Calc is the more promising here, because it should be a really simple macro, but I have no idea where to start.

I found this, but I don't see any way to download it from that webpage, and the "external project page" isn't there any more.
https://extensions.libreoffice.org/extensions/datetime2

I also found some Excel macros for this, which don't work in Calc. The language looks similar, but seems it's not the same.
 
No idea on how this spreadsheet programms work but if you just want to input some numbers we can just automate all the keyboard actions.
Create a shortcut that runs this code:
Code:
#! /bin/bash

s=$(date +%Y%m%d%H%M%S)
xdotool key ${s:0:1} ${s:1:1} ${s:2:1} ${s:3:1} "period" ${s:4:1} ${s:5:1} "period" ${s:6:1} ${s:7:1} "period" ${s:8:1} ${s:9:1} "period" ${s:10:1} ${s:11:1} "period" ${s:12:1} ${s:13:1}
This will store the date inside "s", then starts a keyboard simulation and ${s: POSITION:1} returns the date piece by piece.
On the plus side this wont stay limited to just one program.
Alter as you like,"man date" and "xev" might be usefull for that.
 
Thanks, I'll try that. Working in Gnumeric too is more useful than a Calc macro.
 
https://github.com/komma4/DateTime2

To install an extension, follow these steps:
  • Download dastime2.oxt and save it anywhere on your computer.
  • In LibreOffice, select Tools --> Extension Manager from the menu bar.
  • In the Extension Manager dialog click Add.
  • A file browser window opens. Navigate to the folder where you saved the LibreOffice extension file(s) on your system. The extension's files have the file extension 'OXT'.
Once imported, you'll find it under Tools / Macro's (where you can run it or edit it or add it to a button or a hotkey). Once you know which one to run (text, date, time, etc) you can

get directly to the hotkey thing: Tools | Customize | Keyboard

Took a bit of tinkering, on the bottom, go to your macro
Then choose an empty keyboard combo and press "Modify" to link the hotkey to the macro.
 
Last edited:
Thanks, you found where the extension moved to.

I have something working based on Elw3's idea, so I'll stick with that for now and see how it goes.
 
Back
Top