Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example how to set a due date #339

Open
030 opened this issue Feb 2, 2021 · 7 comments
Open

Example how to set a due date #339

030 opened this issue Feb 2, 2021 · 7 comments
Labels
needs triage Ticket that needs triage (a proper look for classification)

Comments

@030
Copy link

030 commented Feb 2, 2021

I tried to set a Duedate as field:

jira.Issue{
  Fields: &jira.IssueFields{ 
    Duedate: "incorrect format",
  },
}

but I do not seem to get the right format.

@github-actions
Copy link

github-actions bot commented Feb 2, 2021

Hi! Thank you for taking the time to create your first issue! Really cool to see you here for the first time. Please give us a bit of time to review it.

@benjivesterby
Copy link
Contributor

@030 Try one of these format strings in time.Format when setting that field

https://github.com/nortonlifelock/jira/blob/1687038936ca93cf4a856970d669484c58bd0b7c/const.go#L44

@030
Copy link
Author

030 commented Feb 3, 2021

@benjivesterby I tried that, but it does not work. Perhaps the example could be extended with a working example?

@benjivesterby
Copy link
Contributor

@030 I'll see what I can do. It's been a bit since I've had a production JIRA to play with, but I'll try and setup something against my own instance and get back to you. Theoretically though it should only be a formatting issue, but since Due Date is a default field for JIRA I believe you can also just assign a time.Time formatted using the format string 2006-01-02T15:04:05.999-0700 and it should work when pushing the issue. Can you try creating a new issue and setting the Due Date with this code? This should create a ticket that is due in 24 hours.

jira.Issue{
  Fields: &jira.IssueFields{ 
    Duedate: time.Now().Add(time.Hour*24).Format("2006-01-02T15:04:05.999-0700"),
  },
}

Fair warning though, I did not try this code.

@030 030 closed this as completed Jul 21, 2021
@andygrunwald andygrunwald reopened this Jul 21, 2021
@andygrunwald
Copy link
Owner

@030 Hey Ben, did this solve your problem? If yes, it would be a good idea to add this to the example directory.

@rcjames
Copy link

rcjames commented May 9, 2022

When creating the issue the Duedate field seems to need to be of the jira.Date type. I think I've got a working example of this now, but the formatting is a little strange.

dateFormat := "Mon, 2 Jan 2006 15:04:05 GMT"
startDate := "Fri, 22 Apr 2022 14:00:00 GMT"

d, _ := time.Parse(dateFormat, startDate)
dateString := "\"" + d.Format("2006-01-02") + "\""

var dueDate jira.Date
_ = dueDate.UnmarshalJSON([]byte(dateString))

https://go.dev/play/p/bq_2AVmlCmC

I'm not quite sure why the date string needs to contain escaped quotes though. Maybe a copy and paste from the MarshalJSON function? Definitely looks like a bug 🤷

ti, err := time.Parse("\"2006-01-02\"", string(b))

@andygrunwald andygrunwald added the needs triage Ticket that needs triage (a proper look for classification) label Aug 20, 2022
@andygrunwald
Copy link
Owner

Hey,

I am very sorry that this issue has been open for a long time with no final solution. We work on this project in our spare time, and sometimes, other priorities take over. This is the typical open source dilemma.

However, there is news: We are kicking off v2 of this library 🚀

To provide visibility, we created the Road to v2 Milestone and calling for your feedback in #489

The development will take some time; however, I hope you can benefit from the changes.
If you seek priority development for your issue + you like to sponsor it, please contact me.

What does this mean for my issue?

We will work on this issue indirectly.
This means that during the development phase, we aim to tackle it.
Maybe in a different way like it is currently handled.
Please understand that this will take a while because we are running this in our spare time.

Final words

Thanks for using this library.
If there is anything else you would like to tell us, let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Ticket that needs triage (a proper look for classification)
Projects
None yet
Development

No branches or pull requests

4 participants