int main() { char* hostname; int tld; TLDIterator* myiter; TLDNode* pointat; Date* dummydate, *left_date, *right_date; TLDNode *node, *node_left, *node_right, *node_ll, *node_lr; TLDList* mylist; //printf("%s", "|"); left_date = date_create("10/10/1900"); right_date = date_create("10/10/2100"); dummydate = date_create("11/10/1991"); //printf("%d", strcmp("c", "d")); //return strcmp(tldA, tldB); //printf("%d",strcmp("hello", "a(c = getchar()) != EOF)ello")); mylist = tldlist_create(left_date, right_date); tldlist_add(mylist, "www.intel.com", dummydate); //tldlist_add(mylist, ".2", dummydate); //tldlist_add(mylist, "www.dcs.gla.ac.uk", dummydate); //tldlist_add(mylist, "www.mit.edu", dummydate); //tldlist_add(mylist, "www.cms.rgu.ac.uk", dummydate); tldlist_add(mylist, ".f", dummydate); tldlist_add(mylist, ".j", dummydate); tldlist_add(mylist, ".n", dummydate); tldlist_add(mylist, ".a", dummydate); tldlist_add(mylist, ".a", dummydate); //tldlist_add(mylist, ".o", dummydate); //tldlist_add(mylist, ".e", dummydate); //tldlist_add(mylist, ".c", dummydate); //tldlist_add(mylist, ".c", dummydate); //tldlist_add(mylist, ".c", dummydate); //tldlist_add(mylist, ".g", dummydate); //tldlist_add(mylist, ".i", dummydate); //tldlist_add(mylist, ".k", dummydate); //tldlist_add(mylist, ".m", dummydate); //tldlist_add(mylist, ".o", dummydate); //printf("%s", unsafe_inorder(mylist -> head)); //myiter = tldlist_iter_create(mylist); //printf("%s", myiter -> tldnode_ptr -> up -> tld); //printf("%s", "nima"); //if (pointat != NULL) printf("huja"); //printf("%s", myiter -> tldnode_ptr -> tld); /*pointat = tldlist_iter_next(myiter); while (pointat != NULL){ printf("%s%d", tldnode_tldname(pointat), tldnode_count(pointat)); pointat = tldlist_iter_next(myiter); }*/ return 0; }
int main(){ Date* date_year1 = date_create("11/10/1991"); Date* date_year2 = date_create("11/10/1992"); Date* date_month1 = date_create("11/10/1991"); Date* date_month2 = date_create("11/11/1991"); Date* date_day1 = date_create("11/10/1991"); Date* date_day2 = date_create("12/10/1991"); Date* date_same1 = date_create("10/10/1991"); Date* date_same2 = date_create("10/10/1991"); int comp1; int comp2; int comp3; int comp4; int comp5; int comp6; int comp7; int comp8; comp1 = date_compare(date_year1, date_year2); comp2 = date_compare(date_month1, date_month2); comp3 = date_compare(date_day1, date_day2); comp4 = date_compare(date_same1, date_same2); comp5 = date_compare(date_month2, date_month1); comp6 = date_compare(date_year2, date_year1); comp7 = date_compare(date_day2, date_day1); comp8 = date_compare(date_same2, date_same1); printf("%i, %i, %i, %i, %i, %i, %i, %i", comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8); //printf("%i\n", all_chars(&validate_slash, 4, 8, '/', '/', '/')); return 0; }
Date * pgrset_getDate(PGResultSet *rset, int column) { char format[20] = {'\0'}; char *type; pgrset_checkRow(rset); pgrset_checkColumn(rset, &column); CHECK_ROW_BOUNDS(NULL); type = ihtab_get(pgTypes, rset->column_types[column]); if (!estrcmp(type, "abstime")){ memcpy(format, "%Y-%m-%d %H:%M:%S%Z", 19); } else if (!estrcmp(type, "date")){ memcpy(format, "%Y-%m-%d", 8); } else if (!estrcmp(type, "time")){ memcpy(format, "%H:%M:%S", 8); } else if (!estrcmp(type, "timestamp")){ memcpy(format, "%Y-%m-%d %H:%M:%S", 17); } else if (!estrcmp(type, "timetz")){ memcpy(format, "%H:%M:%S%Z", 10); } return date_create(format, PQgetvalue(rset->res, rset->row, column)); }
t_date *ft_date_convert(char *str) { char **ret; t_date *date; ret = ft_strsplit(str, ' '); if (count_char(str, ' ') != 1) return (NULL); if (count_char(str, '/') != 2) return (NULL); if (count_char(str, ':') != 2) return (NULL); if (ret != NULL && ret[1] != NULL && !ret[2]) { if (!(date = date_create())) return (NULL); date_convert_time(ret[0], date); date_convert_date(ret[1], date); ft_tabstrdel(ret); return (date); } return (NULL); }