#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/*============ Substring Function ===================*/
char *substring(size_t start, size_t stop, const char *src, char *dst, size_t size)
{
int count = stop - start;
if ( count >= --size )
{
count = size;
}
sprintf(dst, "%.*s", count, src + start);
return dst;
}
/*=================== Substring Function ==================*/
/*================== Time diff Function ====================*/
int date_diff(char nowdate[20], int diff)
{
int i,maxday,nowday,nowmonth,nowyear,prevday,prevmonth,prevyear,monthdiff,diffyear,len;
long long prevdate;
char tempnowday[2],tempnowmonth[2],tempnowyear[20],tempprevday[2],tempprevmonth[2],tempprevyear[20],resultday[2],resultmonth[2],resultyear[5],result[20];
//printf("nowdate %s\n",nowdate);
substring(0,4,nowdate,tempnowyear,100);
nowyear = atoi(tempnowyear);
//printf("tempnowyear %s\n",tempnowyear);
substring(4,6, nowdate, tempnowmonth, sizeof nowdate);
nowmonth = atoi(tempnowmonth);
substring(6,8,nowdate,tempnowday,sizeof nowdate);
nowday = atoi(tempnowday);
//printf("now year str %s %s %s\n",tempnowyear,tempnowmonth,tempnowday);
//printf("now year int %d %d %d\n",nowyear,nowmonth,nowday);
//printf("diff %d\n",diff);
prevday = nowday - diff;
if (prevday <= 0){
prevmonth = nowmonth - 1;
ความเห็นล่าสุด
1 สัปดาห์ 1 วัน ก่อน
1 สัปดาห์ 2 วัน ก่อน
1 สัปดาห์ 4 วัน ก่อน
1 สัปดาห์ 5 วัน ก่อน
2 สัปดาห์ 6 วัน ก่อน
3 สัปดาห์ 2 วัน ก่อน
3 สัปดาห์ 2 วัน ก่อน
3 สัปดาห์ 2 วัน ก่อน
3 สัปดาห์ 2 วัน ก่อน
3 สัปดาห์ 3 วัน ก่อน