dates can be strings i dont care
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type File string
|
||||
@@ -60,7 +59,7 @@ func (file File) Deltas(like ...Like) ([]Delta, error) {
|
||||
}
|
||||
|
||||
type transaction struct {
|
||||
date time.Time
|
||||
date string
|
||||
description string
|
||||
payee string
|
||||
recipients []transactionRecipient
|
||||
@@ -89,7 +88,7 @@ func (file File) transactions() ([]transaction, error) {
|
||||
if !one.empty() {
|
||||
result = append(result, one)
|
||||
}
|
||||
if errors.Is(err, io.EOF) {
|
||||
if err == io.EOF {
|
||||
return result, nil
|
||||
}
|
||||
if err != nil {
|
||||
@@ -99,5 +98,36 @@ func (file File) transactions() ([]transaction, error) {
|
||||
}
|
||||
|
||||
func readTransaction(r io.Reader) (transaction, error) {
|
||||
return transaction{}, io.EOF
|
||||
result := transaction{}
|
||||
var err error
|
||||
|
||||
if result.date, err = readTransactionDate(r); err != nil {
|
||||
return result, fmt.Errorf("did not find transaction date: %w", err)
|
||||
}
|
||||
|
||||
if result.description, err = readTransactionDescription(r); err != nil {
|
||||
return result, fmt.Errorf("did not find transaction description: %w", err)
|
||||
}
|
||||
|
||||
return transaction{}, errors.New("not impl: reading payee, recipients")
|
||||
}
|
||||
|
||||
func readTransactionDate(r io.Reader) (string, error) {
|
||||
var firstByte [1]byte
|
||||
for firstByte[0] < '0' || firstByte[0] > '9' {
|
||||
if _, err := r.Read(firstByte[:]); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
restOfDate := make([]byte, len("2006-01-02")-1)
|
||||
if _, err := r.Read(restOfDate); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%s", firstByte, restOfDate), nil
|
||||
}
|
||||
|
||||
func readTransactionDescription(r io.Reader) (string, error) {
|
||||
return "", io.EOF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user