• Patch: Elm ME+ 2.5 PLalpha48 -> Elm ME+ 2.5 PLalpha49 [6/9] (4/5)

    From Kari Hurtta@21:1/5 to All on Thu Jan 3 16:43:54 2019
    [continued from previous message]

    ! static char rcsid[] = "@(#)$Id: date.c,v 2.14 2018/12/13 18:01:46 hurtta Exp $";

    /******************************************************************************
    ! * The Elm (ME+) Mail System - $Revision: 2.14 $ $State: Exp $
    *
    * Modified by: Kari Hurtta <hurtta+elm@siilo.FMI.FI>
    * (was hurtta+elm@posti.FMI.FI, hurtta+elm@ozone.FMI.FI)
    ***************
    *** 13,109 ****
    *
    * Copyright (c) 1988-1992 USENET Community Trust
    * Copyright (c) 1986,1987 Dave Taylor
    *****************************************************************************/

    /** return the current date and time in a readable format! **/
    /** also returns an ARPA RFC-822 format date... **/


    - #include "def_elm.h"

    - DEBUG_VAR(Debug,__FILE__,"config");

    ! #ifdef BSD_TYPE
    ! # include <sys/timeb.h>
    ! #endif
    !
    ! #ifndef _POSIX_SOURCE
    ! extern struct tm *localtime();
    ! extern struct tm *gmtime();
    ! extern time_t time();
    ! #endif
    !
    ! #define MONTHS_IN_YEAR 11 /* 0-11 equals 12 months! */
    ! #define FEB 1 /* 0 = January */
    ! #define DAYS_IN_LEAP_FEB 29 /* leap year only */

    ! #define ampm(n) (n > 12? n - 12 : n)
    ! #define am_or_pm(n) (n > 11? (n > 23? "am" : "pm") : "am")

    - int days_in_month[] = { 31, 28, 31, 30, 31, 30,
    - 31, 31, 30, 31, 30, 31, -1};

    ! void days_ahead(days, buffer, size)
    ! int days;
    ! char *buffer;
    ! int size;
    {
    ! /** return in buffer the date (Day, Mon Day, Year) of the date
    ! 'days' days after today.
    ! **/

    ! struct tm *the_time; /* Time structure, see CTIME(3C) */
    ! time_t junk; /* time in seconds.... */

    ! junk = time((time_t *) 0);

    - junk += days * 24 * 60 *60;
    - the_time = localtime(&junk);


    ! elm_sfprintf(buffer, size,
    ! FRM("%s, %d %s %d"),
    ! arpa_dayname[the_time->tm_wday],
    ! the_time->tm_mday,
    ! arpa_monname[the_time->tm_mon],
    ! 1900+the_time->tm_year);
    }


    ! char *
    ! elm_date_str(buf, seconds, size)
    ! char *buf;
    time_t seconds;
    - int size;
    {
    ! struct tm *tmbuf;
    !
    ! tmbuf = gmtime(&seconds);
    !
    ! elm_sfprintf(buf, size,
    ! FRM("%s %d, %d %02d:%02d:%02d %s"),
    ! arpa_monname[tmbuf->tm_mon],
    ! tmbuf->tm_mday,
    ! tmbuf->tm_year+1900,
    ! ampm(tmbuf->tm_hour),
    ! tmbuf->tm_min,
    ! tmbuf->tm_sec,
    ! am_or_pm(tmbuf->tm_hour));
    !
    ! return(buf);
    }

    ! void make_menu_date(entry)
    ! struct header_rec *entry;
    {
    ! struct tm *tmbuf;
    ! time_t seconds;

    ! seconds = entry->time_sent + entry->tz_offset;
    ! tmbuf = gmtime(&seconds);
    ! elm_sfprintf(entry->time_menu, sizeof entry->time_menu,
    ! FRM("%3.3s %-2d"),
    ! arpa_monname[tmbuf->tm_mon], tmbuf->tm_mday);
    }

    /*
    --- 13,409 ----
    *
    * Copyright (c) 1988-1992 USENET Community Trust
    * Copyright (c) 1986,1987 Dave Taylor
    + *****************************************************************************
    + * Incorparated Elm 2.5 code from src/date.c
    + * That code have following copyright:
    + *
    + * The Elm Mail System
    + *
    + * Copyright (c) 1988-1995 USENET Community Trust
    + * Copyright (c) 1986,1987 Dave Taylor
    *****************************************************************************/

    /** return the current date and time in a readable format! **/
    /** also returns an ARPA RFC-822 format date... **/




    ! #include "def_elm.h"

    ! #include "s_me.h"


    ! DEBUG_VAR(Debug,__FILE__,"config");
    !
    ! static unsigned char * s2us P_((char *str));
    ! static unsigned char * s2us(str)
    ! char *str;
    {
    ! return (unsigned char *)str;
    ! }

    ! /* SHRT_MAX */
    ! #include <limits.h>

    ! #define ampm(n) (n > 12? n - 12 : n)
    ! #define am_or