commit a49ed26aed68f00abaf9d48e1ba9c25fa5a311d1
parent c3f6de414aa7ec58d1c876f8545c060940bbf65d
Author: Oliver Lowe <o@olowe.co>
Date: Mon, 30 Jun 2025 15:30:05 +1000
jira: add due date parse, print support
Diffstat:
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/jira/jira.go b/jira/jira.go
@@ -22,6 +22,7 @@ type Issue struct {
Project Project `json:"project"`
Created time.Time `json:"created,omitzero"`
Updated time.Time `json:"updated,omitzero"`
+ Due time.Time `json:"duedate,omitzero"`
Type struct {
Name string `json:"name"`
} `json:"issuetype"`
@@ -102,6 +103,7 @@ func (issue *Issue) UnmarshalJSON(b []byte) error {
iaux := &struct {
Created string `json:"created"`
Updated string `json:"updated"`
+ Due string `json:"duedate"`
Comment map[string]json.RawMessage
IssueLinks []struct {
InwardIssue *Issue
@@ -128,6 +130,12 @@ func (issue *Issue) UnmarshalJSON(b []byte) error {
return fmt.Errorf("updated time: %w", err)
}
}
+ if iaux.Due != "" {
+ issue.Due, err = time.Parse(timestamp, iaux.Due)
+ if err != nil {
+ return fmt.Errorf("due date: %w", err)
+ }
+ }
if bb, ok := iaux.Comment["comments"]; ok {
if err := json.Unmarshal(bb, &issue.Comments); err != nil {
return fmt.Errorf("unmarshal comments: %w", err)
diff --git a/jira/print.go b/jira/print.go
@@ -23,6 +23,9 @@ func printIssue(i *Issue) string {
fmt.Fprintln(buf, "From:", i.Reporter)
}
fmt.Fprintln(buf, "Date:", i.Created.Format(time.RFC1123Z))
+ if !i.Due.IsZero() {
+ fmt.Fprintln(buf, "Due:", i.Due.Format(time.RFC1123Z))
+ }
if i.Assignee != nil {
fmt.Fprintln(buf, "Assignee:", i.Assignee)
}