diff --git a/README.md b/README.md
index 414f498..a6de18d 100644
--- a/README.md
+++ b/README.md
@@ -104,12 +104,12 @@ Imported 4 of 4 loves into listenbrainz.
Latest timestamp: 2023-11-23 14:44:46 +0100 CET (1700747086)
```
-Scotty will remember the latest timestamp for which it transferred data between the two services. The next time you run `scotty beam loves deezer listenbrainz` it will only consider tracks loved after the previous import. If you for some reason want to override this and start importing at an earlier time again, you can specify an earlier start time with the `--timestamp` parameter, which expects a Unix timestamp.
+Scotty will remember the latest timestamp for which it transferred data between the two services. The next time you run `scotty beam loves deezer listenbrainz` it will only consider tracks loved after the previous import. If you for some reason want to override this and start importing at an earlier time again, you can specify an earlier start time with the `--timestamp` parameter, which can be either a Unix timestamp (seconds since 1970-01-01 00:00:00) or a date time string like "2023-12-10 16:12:00".
For example to import listens starting at a specific timestamp use:
```
-scotty beam listens deezer listenbrainz --timestamp 1701872784
+scotty beam listens deezer listenbrainz --timestamp "2023-12-06 14:26:24"
```
diff --git a/cmd/beam_listens.go b/cmd/beam_listens.go
index 149319f..fe567f0 100644
--- a/cmd/beam_listens.go
+++ b/cmd/beam_listens.go
@@ -17,8 +17,6 @@ Scotty. If not, see .
package cmd
import (
- "math"
-
"github.com/spf13/cobra"
"go.uploadedlobster.com/scotty/internal/backends"
"go.uploadedlobster.com/scotty/internal/cli"
@@ -60,5 +58,5 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// beamListensCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
- beamListensCmd.Flags().Int64P("timestamp", "t", math.MinInt64, "Only import listens newer then given Unix timestamp")
+ beamListensCmd.Flags().StringP("timestamp", "t", "", "only import listens newer then given timestamp")
}
diff --git a/cmd/beam_loves.go b/cmd/beam_loves.go
index 19063db..5f75d70 100644
--- a/cmd/beam_loves.go
+++ b/cmd/beam_loves.go
@@ -17,8 +17,6 @@ Scotty. If not, see .
package cmd
import (
- "math"
-
"github.com/spf13/cobra"
"go.uploadedlobster.com/scotty/internal/backends"
"go.uploadedlobster.com/scotty/internal/cli"
@@ -60,5 +58,5 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// beamLovesCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
- beamLovesCmd.Flags().Int64P("timestamp", "t", math.MinInt64, "Only import loves newer then given Unix timestamp")
+ beamLovesCmd.Flags().StringP("timestamp", "t", "", "only import loves newer then given timestamp")
}
diff --git a/internal/cli/transfer.go b/internal/cli/transfer.go
index 5683bb6..1af552e 100644
--- a/internal/cli/transfer.go
+++ b/internal/cli/transfer.go
@@ -16,8 +16,8 @@ Scotty. If not, see .
package cli
import (
+ "errors"
"fmt"
- "math"
"strconv"
"sync"
"time"
@@ -155,13 +155,29 @@ func (c *TransferCmd[E, I, R]) Transfer(exp backends.ExportProcessor[R], imp bac
}
func (c *TransferCmd[E, I, R]) timestamp() (time.Time, error) {
- flagValue, err := c.cmd.Flags().GetInt64("timestamp")
- if err == nil && flagValue > math.MinInt64 {
- return time.Unix(flagValue, 0), nil
- } else {
+ flagValue, err := c.cmd.Flags().GetString("timestamp")
+ if err != nil {
+ return time.Time{}, err
+ }
+
+ // No timestamp given, read from database
+ if flagValue == "" {
timestamp, err := c.db.GetImportTimestamp(c.sourceName, c.targetName, c.entity)
return timestamp, err
}
+
+ // Try using given value as a Unix timestamp
+ if timestamp, err := strconv.ParseInt(flagValue, 10, 64); err == nil {
+ return time.Unix(timestamp, 0), nil
+ }
+
+ // Try to parse datetime string
+ for _, format := range []string{time.DateTime, time.RFC3339} {
+ if t, err := time.Parse(format, flagValue); err == nil {
+ return t, nil
+ }
+ }
+ return time.Time{}, errors.New(i18n.Tr("invalid timestamp string \"%v\"", flagValue))
}
func (c *TransferCmd[E, I, R]) updateTimestamp(result models.ImportResult, oldTimestamp time.Time) error {