logo

gemini-space

What lives at gemini://hacktivis.me/ git clone https://hacktivis.me/git/gemini-space.git
commit: b01cca832898f0c1177457cce3000071ed5d47d2
parent e6738b3db544c26f82835493ce796e62df658f1c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 21 Feb 2021 16:25:52 +0100

cgi-*/mdate*: New cgi-bin executable

Diffstat:

AMakefile12++++++++++++
Acgi-bin/mdate0
Acgi-src/mdate.c18++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,12 @@ +BINS = cgi-bin/mdate +CFLAGS = -Os +STRIP = strip +all: ${BINS} + +cgi-bin/mdate: cgi-src/mdate.c + $(CC) -std=c11 $(CFLAGS) $(LDFLAGS) -o $@ $< + $(STRIP) cgi-bin/mdate + +.PHONY: clean +clean: + rm -f ${BINS} diff --git a/cgi-bin/mdate b/cgi-bin/mdate Binary files differ. diff --git a/cgi-src/mdate.c b/cgi-src/mdate.c @@ -0,0 +1,18 @@ +#define _POSIX_C_SOURCE 200809L +#include <time.h> /* time */ +#include <stdio.h> /* printf */ + +// 3600*24.5 +#define cycle 88200 + +int +main(void) { + time_t now = time(NULL); + time_t date_now = now / cycle; + time_t time_now = now % cycle; + + printf("20 text/gemini; charset=utf-8\r\n"); + printf("On a 24.5h cycle it is now: %lX,%05lX\n", date_now, time_now); + + return 0; +}