mirror of
https://github.com/Xevion/banner.git
synced 2025-12-10 22:06:34 -06:00
ParseNaiveTime in MeetingTime API call
This commit is contained in:
12
api.go
12
api.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -33,10 +34,15 @@ func GetTerms(search string, offset int, max int) ([]Term, error) {
|
|||||||
onRequest(req)
|
onRequest(req)
|
||||||
res, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
onResponse(res)
|
onResponse(res)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print the response body
|
||||||
|
body, _ := io.ReadAll(res.Body)
|
||||||
|
log.Printf("Response Body: %s", body)
|
||||||
|
|
||||||
// Assert that the response is JSON
|
// Assert that the response is JSON
|
||||||
if !ContainsContentType(res.Header.Get("Content-Type"), "application/json") {
|
if !ContainsContentType(res.Header.Get("Content-Type"), "application/json") {
|
||||||
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
|
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
|
||||||
@@ -302,8 +308,10 @@ func GetCourseMeetingTime(term int, crn int) (*MeetingTimeResponse, error) {
|
|||||||
const layout = "01/02/2006"
|
const layout = "01/02/2006"
|
||||||
dateStart, _ := time.Parse(layout, meetingTimeMap["startDate"].(string))
|
dateStart, _ := time.Parse(layout, meetingTimeMap["startDate"].(string))
|
||||||
dateEnd, _ := time.Parse(layout, meetingTimeMap["endDate"].(string))
|
dateEnd, _ := time.Parse(layout, meetingTimeMap["endDate"].(string))
|
||||||
timeStart, _ := strconv.ParseUint(meetingTimeMap["beginTime"].(string), 10, 0)
|
timeStartInt, _ := strconv.ParseUint(meetingTimeMap["beginTime"].(string), 10, 0)
|
||||||
timeEnd, _ := strconv.ParseUint(meetingTimeMap["endTime"].(string), 10, 0)
|
timeStart := ParseNaiveTime(timeStartInt)
|
||||||
|
timeEndInt, _ := strconv.ParseUint(meetingTimeMap["endTime"].(string), 10, 0)
|
||||||
|
timeEnd := ParseNaiveTime(timeEndInt)
|
||||||
|
|
||||||
// Extract faculty data
|
// Extract faculty data
|
||||||
faculty := make([]MeetingTimeFaculty, 0)
|
faculty := make([]MeetingTimeFaculty, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user