   }
 
   // try to read the Date line in the http headers
-  char line[256];
+  dateline l;
   size_t pos = 0;
   bool wehaveadate = 0;
   unsigned long lastRead = millis();
   while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
     while (www.available()) {
       char c = www.read();
-      if (c == '\n') { // we've reached a newline
-        line[pos++] = 0;
+      if (c == '\n' || pos > LINELEN-2) { // we've reached a newline
         pos = 0;
         // now we need to see whether this is the 'Date:' line
-        if (line[0] == 'D' &&
-            line[1] == 'a' &&
-            line[2] == 't' &&
-            line[3] == 'e' &&
-            line[4] == ':') { // seriously? TODO: fix this shit
+        if (!strcmp(l.fields.date, "Date:")) { 
           wehaveadate = 1;
         }
       } else if (!wehaveadate) { // if we haven't reached a newline, put it in the buffer
-        line[pos] = c;
-        line[pos + 1] = 0;
+        if (pos == 5 ||
+            pos == 9 ||
+            pos == 13||
+            pos == 17||
+            pos == 22||
+            pos == 25||
+            pos == 28||
+            pos == 31) { // putting the nulls in the right place for field seperators
+          l.line[pos] = 0;
+        } else {
+          l.line[pos] = c;
+        }
+        l.line[pos + 1] = 0;
         pos++;
       }
       lastRead = millis();


DateTime now = DateTime(0);

uint8_t parseMonth (char *mo) {
  if (!strcmp(mo, "Jan")) {
    return 1;

  }
}


/**
 * connects to a web server and parses its HTTP Date: header to get the current DateTime
 */
DateTime parseHeader(uint32_t ip, uint16_t port, char *host, char *path) {
  #define LINELEN 256
  /**
   * holds the HTTP Date header line, which fortunately has fixed with fields
   * Date: Tue 15 Nov 1994 08:12:31 GMT
   */
  typedef union dateline
  {
    char line[LINELEN];
    struct fields {
      char date[6];
      char dow[4]; char pad; 
      char dom[3]; char mmm[4]; char yyyy[5];
      char hh[3]; char mm[3]; char ss[3];
      char tz[4];
    } fields;
  } dateline;

  // first connect to the site we're gonna leech the datetime from
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, port);
  if (www.connected()) {
