Ask a Question related to Ruby, Design and Development.

  1. #1

    Default SMTP Date format?

    Hey all,

    Is there already code which formats a date into the format required for SMTP?

    [url]http://ftp.rfc-editor.org/in-notes/rfc2822.txt[/url]

    See sec 3.3

    I've been writing my own version, but it really seems like it must have
    already been done.

    Ben


    Ben Giddings Guest

  2. Similar Questions and Discussions

    1. Date format 07-JUL-03
      What's the simplest format method to force the medium date format to capitalize the month, like 07-JUL-03 instead of 07-Jul-03 in a form text box?...
    2. Date Format in Com+
      Hi All, I have one Component in VB6. My component receive a date as string parameter ("dd/MM/yyyy"). My componente understand "MM/dd/yyyy". Then I...
    3. Date() Format
      Hi Im trying to get a mm/dd/ccyy format and can nearly do this using date() however I for 02 Feb 2004 I get 2/2/2004 and I want 02/02/2004
    4. converting date into database date format(newbie)
      Hi! U can convert "8-Aug-03" into mysql date which requires yyyy-mm-dd format as below. <?php date("Y-m-d",strtotime("8-Aug-03")); ?>
    5. Date format Help.
      I have a field set to short date 99;99;00;0, and it appears as soon as I tab to the next couple of fields that the previous date field changes to...
  3. #2

    Default Re: SMTP Date format?

    In article <200307221635.02170.ben@thingmagic.com>,
    Ben Giddings <ben@thingmagic.com> writes:
    > Is there already code which formats a date into the format required for SMTP?
    >
    > [url]http://ftp.rfc-editor.org/in-notes/rfc2822.txt[/url]
    time.rb which is bundled since 1.6.7 has Time#rfc2822.

    % ruby -rtime -e 'p Time.now.rfc2822'
    "Wed, 23 Jul 2003 09:29:05 +0900"
    --
    Tanaka Akira

    Tanaka Akira Guest

  4. #3

    Default Re: SMTP Date format?

    On Wed July 23 2003 9:35 am, Josef 'Jupp' Schugt wrote:
    > * Ben Giddings; 2003-07-22, 20:38 UTC:
    > > Is there already code which formats a date into the format required
    > > for SMTP?
    >
    > What exactly can strftime not do for you?
    Well the tough part was going to be the timezone offset part:

    Date: Wed, 23 Jul 2003 22:35:49 +0900
    ^^^^^

    But now that I found the time library which does the formatting I'm set.

    While we're on the subject though, what's the recommended method for
    determining your timezone offset in Ruby?

    Ben


    Ben Giddings Guest

  5. #4

    Default Re: SMTP Date format?

    On Thu, Jul 24, 2003 at 01:22:33AM +0900, Josef 'Jupp' Schugt wrote:
    > On Thu, 24 Jul 2003, Ben Giddings wrote:
    >
    >
    > > But now that I found the time library which does the formatting I'm
    > > set.
    > >
    > > While we're on the subject though, what's the recommended method
    > > for determining your timezone offset in Ruby?
    >
    > On my system (at home) the only reliable method would be asking the
    > user to provide it. The machine is running on UTC while the official
    > timezone is MESZ (UTC+2).
    But Unix machines, although they "run" on UTC, can be configured with a
    local timezone. This is the time you will see when you run the 'date'
    command, for example. On most machines I've seen this is set by creating
    /etc/localtime as a symlink to /usr/share/zoneinfo/<whatever>; it can also
    be overriden by setting environment variable TZ.

    In many parts of the world the timezone offset varies throughout the year,
    but with a modern implementation of localtime() it will tell you it:

    #include <stdio.h>
    #include <time.h>
    int main(void)
    {
    time_t now = time(NULL);
    struct tm *tm = localtime(&now);
    printf("The current timezone name is %s\n",tm->tm_zone);
    printf("The current timezone offset is %ld secs from GMT\n",tm->tm_gmtoff);
    return 0;
    }

    When I run this I get:

    The current timezone name is BST
    The current timezone offset is 3600 secs from GMT

    (I am in the UK). So the information is there - whether there's a Ruby
    wrapper for it I don't know.

    If you're on a Windows machine though, you're in a whole different sorry
    state. At work I get E-mails from people using Outlook calendar saying
    "meeting scheduled for 14:00 GMT (London, Lisbon, ...)" when in fact they
    mean 2pm local time, which in the summer is 13:00 GMT. The clock is actually
    moved forwards and backwards when daylight savings starts and ends, instead
    of calculating the offset. If you turn your computer on at 1.30am on the day
    that the change takes place, your computer has no idea what the correct time
    is.

    Cheers,

    Brian.

    Brian Candler Guest

  6. #5

    Default Re: SMTP Date format?

    Saluton!

    * Brian Candler; 2003-07-24, 12:25 UTC:
    > When I run this I get:
    >
    > The current timezone name is BST
    > The current timezone offset is 3600 secs from GMT
    UTC, no offset here. Principle of least trouble.

    Gis,

    Josef 'Jupp' Schugt
    --
    N'attribuez jamais à la malice ce que l'incompétence explique !
    -- Napoléon

    Josef 'Jupp' Schugt Guest

  7. #6

    Default Re: SMTP Date format?

    On Fri, Jul 25, 2003 at 04:14:25AM +0900, Trevor Jenkins wrote:
    > I don't believe in BST so there's no surprise that all my systems here, in
    > London, report:
    >
    > The current timezone name is GMT
    > The current timezone offset is 0 secs from GMT
    >
    > Which is as it should be.
    Well, each to his own. If you're parsing crappy log files that don't store
    the time unambiguously, then I agree that local time could be a problem.

    Cheers,

    Brian.

    Brian Candler Guest

  8. #7

    Default Re: SMTP Date format?

    Thank you, Tanaka Akira!

    With non-rfc2822 date formats, the Android email app displays dates as "12/31/1969" and places emails at the bottom of the inbox.
    Ian M Dew Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139