@@ -22,13 +22,19 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
2222 @IBOutlet weak var tableViewContainerView : UIView !
2323
2424 let apiURL = NSURL ( string: " https://hackfsu.com/api/hackathon/get/updates " ) !
25+ let scheduleapiURL = NSURL ( string: " https://hackfsu.com/api/hackathon/get/schedule_items " ) !
26+
2527 var titles = [ String] ( )
2628 var contents = [ String] ( )
29+ var updatesDates = [ String] ( )
2730
28- var refreshControl : UIRefreshControl !
31+ var scheduleNames = [ String ] ( )
2932
33+ var refreshControl : UIRefreshControl !
3034 var alamoCalled = false ;
3135
36+ /**********************************************************************************/
37+
3238 // MARK: Class Variables
3339 var updateFeedArray : [ HFUpdate ] = [ HFUpdate] ( )
3440 var twitterFeedArray : [ HFScheduleItem ] = [ HFScheduleItem] ( )
@@ -42,6 +48,8 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
4248 var dayOfWeekArray : [ String ] = [ String] ( )
4349 // var feedSegmentControl:UISegmentedControl!
4450
51+ /**********************************************************************************/
52+
4553 override func viewDidLoad( ) {
4654 super. viewDidLoad ( )
4755 feedTableView. setContentOffset ( CGPointZero, animated: false )
@@ -79,6 +87,10 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
7987 feedTableView. addSubview ( refreshControl)
8088
8189 callAlamo ( apiURL)
90+ callAlamo ( scheduleapiURL) ;
91+
92+
93+
8294
8395 }
8496
@@ -108,24 +120,43 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
108120 Alamofire . request ( . GET, url, encoding: . JSON) . validate ( ) . responseJSON ( completionHandler: {
109121
110122 response in
111- self . parseResults ( JSON ( response. result. value!) )
123+ self . parseResults ( JSON ( response. result. value!) , url : url )
112124 self . alamoCalled = true
113125
114126 } )
115127 }
116128
117- func parseResults( theJSON : JSON ) {
129+ func parseResults( theJSON : JSON , url: NSURL ) {
130+
131+ if ( url == apiURL) {
132+
118133 for result in theJSON [ " updates " ] . arrayValue {
119134 let title = result [ " title " ] . stringValue
120135 let content = result [ " content " ] . stringValue
136+ let dates = result [ " submit_time " ] . stringValue
137+
121138 self . contents. append ( content)
122139 self . titles. append ( title)
140+ self . updatesDates. append ( dates)
141+
123142 }
124- for i in self . titles {
125- print ( i)
143+
126144 }
145+ else if ( url == scheduleapiURL) {
146+ for results in theJSON [ " schedule_items " ] . arrayValue {
147+ let name = results [ " name " ] . stringValue
148+ self . scheduleNames. append ( name)
149+ }
150+
151+ }
152+
153+ // for i in self.scheduleNames {
154+ // print(i)
155+ // }
127156 self . feedTableView. reloadData ( )
128157 }
158+
159+
129160
130161
131162
@@ -176,10 +207,11 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
176207 cell. title. text = titles [ indexPath. section]
177208 //cell.subTitle.text = update.getContent()
178209 cell. subTitle. text = contents [ indexPath. section]
179- //print(update.getTimestamp())
180- //cell.timestamp.text = update.getTimestamp()
181- cell. timestamp. text = " temp "
182- //print(update.getTimestamp())
210+
211+ let hi = updatesDates [ indexPath. section]
212+
213+ cell. timestamp. text = theTIMEBIH ( hi) ;
214+
183215 cell. configureFlatCellWithColor ( tempCellColor, selectedColor: tempCellColor, roundingCorners: . AllCorners)
184216 cell. cornerRadius = 3.5
185217 cell. backgroundColor = UIColor . colorFromHex ( 0xEDECF3 )
@@ -283,6 +315,20 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
283315 }
284316 }
285317
318+ func theTIMEBIH( date: String ) -> String {
319+
320+ let dateFormatterGet = NSDateFormatter ( )
321+ dateFormatterGet. dateFormat = " yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ "
322+
323+ let dateFormatterPrint = NSDateFormatter ( )
324+ dateFormatterPrint. dateFormat = " E h:mm a "
325+
326+ let date : NSDate ? = dateFormatterGet. dateFromString ( date)
327+
328+
329+ return dateFormatterPrint. stringFromDate ( date!)
330+ }
331+
286332
287333
288334
@@ -295,6 +341,7 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
295341// getScheduleItemsFromParse()
296342 }
297343
344+
298345 /* checkForContent will check if there is data to be displayed in the view. If not, it will set the correct Glyptodon view. */
299346 /*
300347 func checkForContent() {
@@ -406,7 +453,7 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
406453 }
407454 }
408455 }
409- */
456+
410457
411458 func dateToString(date: NSDate) -> String {
412459 //format date
@@ -455,14 +502,17 @@ class HFFeedViewController: UIViewController, UITableViewDelegate, UITableViewDa
455502 //format date
456503
457504 let dateFormatter = NSDateFormatter()
458- dateFormatter. dateFormat = " hh :mm a "
505+ dateFormatter.dateFormat = "yyyy-MM-dd'T'HH :mm:ssZZZZZ "
459506// let dateString = dateFormatter.stringFromDate(date.dateByAddingTimeInterval(18000))
460507 let dateString = dateFormatter.stringFromDate(date)
508+
461509 let timeComponents = dateString.componentsSeparatedByString(":")
462510 let hour = Int(timeComponents[0])
463511
512+ print("\(hour!):\(timeComponents[1])")
513+
464514 return "\(hour!):\(timeComponents[1])"
465515
466516 }
467-
468- } // End of View Controller Class
517+ */
518+ }
0 commit comments