store

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DBFileName = "store.mindtick"

Variables

View Source
var (
	StrToRange = map[string]Range{
		"today":     TODAY,
		"yesterday": YESTERDAY,
		"week":      WEEK,
		"month":     MONTH,
	}
	RangeToStr = map[Range]string{
		TODAY:     "today",
		YESTERDAY: "yesterday",
		WEEK:      "week",
		MONTH:     "month",
	}
	RangeToTime = map[Range]func() time.Time{
		TODAY: func() time.Time {
			now := time.Now()
			return time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
		},
		YESTERDAY: func() time.Time {
			now := time.Now()
			yesterday := now.AddDate(0, 0, -1)
			return time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, now.Location())
		},
		WEEK: func() time.Time {
			now := time.Now()
			weekAgo := now.AddDate(0, 0, -7)
			return time.Date(weekAgo.Year(), weekAgo.Month(), weekAgo.Day(), 0, 0, 0, 0, now.Location())
		},
		MONTH: func() time.Time {
			now := time.Now()
			monthAgo := now.AddDate(0, -1, 0)
			return time.Date(monthAgo.Year(), monthAgo.Month(), monthAgo.Day(), 0, 0, 0, 0, now.Location())
		},
	}
	RangeOrder = []Range{TODAY, YESTERDAY, WEEK, MONTH}
)

Functions

func AddMessage

func AddMessage(db *sql.DB, message messages.Message) error

func ChangeTimestamp added in v0.2.0

func ChangeTimestamp(db *sql.DB, id int, timestamp time.Time) error

`mindtick edit` command?

func Delete

func Delete() error

func LoadMindtick

func LoadMindtick() (*sql.DB, error)

func Messages added in v0.1.8

func Messages(db *sql.DB, tag messages.Tag, rangeType Range) ([]messages.Message, error)

func New

func New() error

`mindtick new` command

Types

type Range added in v0.1.8

type Range uint8
const (
	ANYTIME Range = iota
	TODAY
	YESTERDAY
	WEEK
	MONTH
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL