sgtoj / PSConnectWise

PowerShell Module that provide several CmdLets to interact with ConnectWise REST API service.
MIT License
45 stars 13 forks source link

ConnectWise time normalization #40

Open mrmarkwest opened 7 years ago

mrmarkwest commented 7 years ago

In trying to do a Create-CWConfig function, I ran into this terrible annoyance with the way that CW needs to receive [datetime] via the API. I wrote this little function that helps. Figured it would help you and your users so they didn't bang their head against the same problems I did.

function ConvertTo-CWTime { Param ( [Parameter(Mandatory = $True,Position = 0)] [datetime]$dateTime ) $MyTZone = Get-TimeZone $datetime = "{0:yyyy-MM-ddThh:mm:ssZ}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($dateTime, $MyTZone) return $datetime }

BrianBtheITguy commented 7 years ago

This may have been repaired as I just used:

Add-CWTimeEntry -TicketID 140830 -MemberID 150 -Start "April 6, 2017 8:00:00 AM" -End "April 6 2017 5:00:00 PM" -Message @"MULTILINE STRING"@ -AddToDescription

with no issue. Either there is a specific issue with Create-CWConfig (which I don't see in the repository), your PC's Region/Language settings, or it's gone away.

Regardless thanks for the tip. Added this to my scripts folder. :)

mrmarkwest commented 7 years ago

Thanks sir, trying to figure out how to contribute... As I'd really like to add on what I've done and not re-do what you have already done.

mrmarkwest commented 7 years ago

So, I've come across this issue again, when I am attempting to create an Agreement.

  "code": "UnsupportedFormat",
  "message": "Unsupported format applied to startDate",
  "resource": "agreement",
  "field": "startDate"

I wonder if it is that I am only needing to pass a date in my example, and you have to define time as well. hmm..

sgtoj commented 7 years ago

@mrmarkwest I welcome contributions. You will need to fork master, commit the changes to your fork, then submit pull requests.

BrianBtheITguy commented 7 years ago

If you check out page #41 you will see that some other issues like this. I think it has to do with Zulu time being used instead of local time.