<commit_before>// vim:ts=8:expandtab
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>

#include "i3status.h"

/* define fixed output-Strings */
char *season_long[5] = {
        "Chaos",
        "Discord",
        "Confusion",
        "Bureaucracy",
        "The Aftermath"
};

char *season_short[5] = {
        "Chs",
        "Dsc",
        "Cfn",
        "Bcy",
        "Afm"
};

char *day_long[5] = {
        "Sweetmorn",
        "Boomtime",
        "Pungenday",
        "Prickle-Prickle",
        "Setting Orange"
};

char *day_short[5] = {
        "SM",
        "BT",
        "PD",
        "PP",
        "SO"
};

char *holidays[10] = {
        "Mungday",
        "Mojoday",
        "Syaday",
        "Zaraday",
        "Maladay",
        "Chaoflux",
        "Discoflux",
        "Confuflux",
        "Bureflux",
        "Afflux"
};

/* A helper-struct, taking the discordian date */
struct disc_time {
        int year;
        int season;
        int week_day;
        int season_day;
        int st_tibs_day;
};

/* Print the date *dt in format *format */
static int format_output(char *outwalk, char *format, struct disc_time *dt) {
        char *orig_outwalk = outwalk;
        char *i;
        char *tibs_end = 0;

        for (i = format; *i != '\0'; i++) {
                if (*i != '%') {
                        *(outwalk++) = *i;
                        continue;
                }
                switch (*(i+1)) {
                        /* Weekday in long and abbreviation */
                        case 'A':
                                outwalk += sprintf(outwalk, "%s", day_long[dt->week_day]);
                                break;
                        case 'a':
                                outwalk += sprintf(outwalk, "%s", day_short[dt->week_day]);
                                break;
                        /* Season in long and abbreviation */
                        case 'B':
                                outwalk += sprintf(outwalk, "%s", season_long[dt->season]);
                                break;
                        case 'b':
                                outwalk += sprintf(outwalk, "%s", season_short[dt->season]);
                                break;
                        /* Day of the season (ordinal and cardinal) */
                        case 'd':
                                outwalk += sprintf(outwalk, "%d", dt->season_day + 1);
                                break;
                        case 'e':
                                outwalk += sprintf(outwalk, "%d", dt->season_day + 1);
                                switch (dt->season_day) {
                                        case 0:
                                                outwalk += sprintf(outwalk, "st");
                                                break;
                                        case 1:
                                                outwalk += sprintf(outwalk, "nd");
                                                break;<commit_msg>Reduce the season day to 0-9 to properly print ordinal suffixes<commit_after>// vim:ts=8:expandtab
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>

#include "i3status.h"

/* define fixed output-Strings */
char *season_long[5] = {
        "Chaos",
        "Discord",
        "Confusion",
        "Bureaucracy",
        "The Aftermath"
};

char *season_short[5] = {
        "Chs",
        "Dsc",
        "Cfn",
        "Bcy",
        "Afm"
};

char *day_long[5] = {
        "Sweetmorn",
        "Boomtime",
        "Pungenday",
        "Prickle-Prickle",
        "Setting Orange"
};

char *day_short[5] = {
        "SM",
        "BT",
        "PD",
        "PP",
        "SO"
};

char *holidays[10] = {
        "Mungday",
        "Mojoday",
        "Syaday",
        "Zaraday",
        "Maladay",
        "Chaoflux",
        "Discoflux",
        "Confuflux",
        "Bureflux",
        "Afflux"
};

/* A helper-struct, taking the discordian date */
struct disc_time {
        int year;
        int season;
        int week_day;
        int season_day;
        int st_tibs_day;
};

/* Print the date *dt in format *format */
static int format_output(char *outwalk, char *format, struct disc_time *dt) {
        char *orig_outwalk = outwalk;
        char *i;
        char *tibs_end = 0;

        for (i = format; *i != '\0'; i++) {
                if (*i != '%') {
                        *(outwalk++) = *i;
                        continue;
                }
                switch (*(i+1)) {
                        /* Weekday in long and abbreviation */
                        case 'A':
                                outwalk += sprintf(outwalk, "%s", day_long[dt->week_day]);
                                break;
                        case 'a':
                                outwalk += sprintf(outwalk, "%s", day_short[dt->week_day]);
                                break;
                        /* Season in long and abbreviation */
                        case 'B':
                                outwalk += sprintf(outwalk, "%s", season_long[dt->season]);
                                break;
                        case 'b':
                                outwalk += sprintf(outwalk, "%s", season_short[dt->season]);
                                break;
                        /* Day of the season (ordinal and cardinal) */
                        case 'd':
                                outwalk += sprintf(outwalk, "%d", dt->season_day + 1);
                                break;
                        case 'e':
                                outwalk += sprintf(outwalk, "%d", dt->season_day + 1);
                                switch (dt->season_day % 10) {
                                        case 0:
                                                outwalk += sprintf(outwalk, "st");
                                                break;
                                        case 1:
                                                outwalk += sprintf(outwalk, "nd");
                                                break;
{'fraction_non_alphanumeric': 0.1233381387153612, 'fraction_numerical': 0.005446099631587378, 'mean_word_length': 0.9872692552514322, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663166', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1681, 'n_words': 390}