vwbusguy, (edited )
@vwbusguy@mastodon.online avatar

Doing datetime evals in #bash always makes me a bit sad that #python's built in datetime is so janky.

knu,
@knu@toot.community avatar

@vwbusguy
Suggestion:
import sqlite3 and use the SQLite date/time functions. No database required. It will be faster than shelling out to bash al the time.

https://www.sqlite.org/lang_datefunc.html

#python #sqlite #bash

vwbusguy,
@vwbusguy@mastodon.online avatar

@knu Story time. One place I worked at had a custom php cms. The function in it for getting the current time made a mysql database call to NOW() to get the current time and called that function constantly. I replaced that with the php built in and performance slightly improved.

vwbusguy,
@vwbusguy@mastodon.online avatar

Getting epoch time from exactly six months ago from now is a simple one liner in due to date from coreutils. No pipes, etc, necessary.

date -d"6 months ago" '+%s'

But you can also use printf builtin with bash if you need something more verbose or want to assign a datetime variable directly.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • vwfavf
  • rosin
  • slotface
  • khanakhh
  • InstantRegret
  • PowerRangers
  • kavyap
  • tsrsr
  • everett
  • mdbf
  • Leos
  • hgfsjryuu7
  • tacticalgear
  • ethstaker
  • osvaldo12
  • ngwrru68w68
  • GTA5RPClips
  • Durango
  • modclub
  • cisconetworking
  • cubers
  • tester
  • normalnudes
  • anitta
  • All magazines