summaryrefslogtreecommitdiff
path: root/pages.c
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2019-12-28 01:56:15 +1030
committerDaniel Jones <admin@danieljon.es>2019-12-28 01:56:15 +1030
commit93a4e3f741a8e37967915fd8b51f651992662d76 (patch)
treedd4f735b0f7c8a85d591de6f6b2998b121f2f18d /pages.c
parent39b4a8695a0e357e3f4a65e290cf3a3c1ca39b82 (diff)
downloadwebsitegenerator-93a4e3f741a8e37967915fd8b51f651992662d76.tar.gz
websitegenerator-93a4e3f741a8e37967915fd8b51f651992662d76.zip
implement gettime()
Diffstat (limited to 'pages.c')
-rw-r--r--pages.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/pages.c b/pages.c
index b6c396a..d9e2e8f 100644
--- a/pages.c
+++ b/pages.c
@@ -307,6 +307,7 @@ replaceinpage(const char *outfile, const char *toreplace, struct fileorstring *s
* replace 'toreplace' in file 'outfile' taking 'infile' as input
* return 1 on success, 0 on failure
*/
+
long substrpos = -1;
substrpos = findstring(frontpage_index_output, toreplace);
@@ -329,9 +330,16 @@ replaceinpage(const char *outfile, const char *toreplace, struct fileorstring *s
}
char
-*gettime()
+*gettime(char *buffer, size_t size)
{
- return "10/10/2019";
+ /*
+ * put the current date into a buffer and return it
+ */
+
+ time_t t = time(NULL);
+ struct tm tm = *localtime(&t);
+ snprintf(buffer, size, "%d/%d/%d", tm.tm_mday, tm.tm_mon+1, tm.tm_year + 1900);
+ return buffer;
}
int
@@ -357,10 +365,11 @@ frontpage(int flags)
return 0;
}
+ char date[255];
struct fileorstring index = {frontpage_index, NULL};
struct fileorstring title = {NULL, frontpage_title};
struct fileorstring info = {NULL, frontpage_info};
- struct fileorstring time = {NULL, gettime()};
+ struct fileorstring time = {NULL, gettime(date, 255)};
if (!replaceinpage(frontpage_index_output, content_string, &index) ||
!replaceinpage(frontpage_index_output, title_string, &title) ||
!replaceinpage(frontpage_index_output, info_string, &info) ||
@@ -369,9 +378,6 @@ frontpage(int flags)
fprintf(stderr, "unable to generate frontpage\n");
return 0;
}
- //remove("title.tmp");
- //remove("date.tmp");
- //remove("info.tmp");
return 1;
}