9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Skip Tavakkolian <skip.tavakkolian@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] silly question
Date: Tue,  2 Sep 2014 14:10:57 -0700	[thread overview]
Message-ID: <CAJSxfm+vDRwVqZGxJK1rDvJnj7AF0VJSW80yMCFxCe2awF8F+w@mail.gmail.com> (raw)
In-Reply-To: <20140902200400.81EAAB827@mail.bitblocks.com>

inspired me to write discotime:

% cat discotime.go
// print the number of seconds from the dawn of Disco until the date
in the argument
package main

import (
    "fmt"
    "os"
    "time"
)

func main() {
    for _, s := range os.Args[1:] {
        d, err := time.Parse(time.UnixDate, s)
        if err != nil {
            panic(err)
        }
        fmt.Println(d.Unix())
    }
}
% ./discotime 'Tue Aug 16 17:03:52 CDT 1977'
240599032

to make a hammertime (http://en.wikipedia.org/wiki/U_Can't_Touch_This)
you can subtract 1990 from parsed date instead.

-Skip


On Tue, Sep 2, 2014 at 1:04 PM, Bakul Shah <bakul@bitblocks.com> wrote:
> On Tue, 02 Sep 2014 15:10:56 EDT erik quanstrom <quanstro@quanstro.net> wrote:
>> > Strftime is a red herring (sorry), I can use  and "date" | getline
>> > to generate pretty much any date string I need.
>> >
>> > The issue is more going the other way. tm2sec in awk is quite complex
>> > and hids many pitfalls if you want to do it correctly.
>> >
>> > My problem is parsing logfiles which contain dates in the form
>> > of date(1) / ctime(2).
>> >
>> > I want to graph stuff over time and so I want a monotonically incrementing
>> > number (secs sinc 1/1/70 would be ideal). I have coded this in awk but
>> > for one year leap years break - though not by much.
>>
>> if the hair is just leap years, the algorithm used by /sys/src/libc/9sys/ctim
>> e.c
>> is pretty attractive.  the idea is to just loop through the years between giv
>> en
>> and 1970, and add a day for each leap year encountered.  should be easy
>> to do in awk.
>
> plan9 doesn't deal with leap seconds, right?  There've been 35
> leap seconds since 1972 (International Atomic Time is 35
> seconds ahead of GMT).  Though this probably doesn't matter
> for timestamps in log files.
>



  parent reply	other threads:[~2014-09-02 21:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02  7:07 Steve Simon
2014-09-02  8:27 ` lucio
2014-09-02  8:46 ` arnold
2014-09-02  9:40   ` Jens Staal
2014-09-02 14:07     ` arnold
2014-09-02 14:22   ` Steve Simon
2014-09-02 14:29     ` arnold
2014-09-02 17:02 ` erik quanstrom
2014-09-02 18:18   ` Steve Simon
2014-09-02 19:10     ` erik quanstrom
2014-09-02 20:04       ` Bakul Shah
2014-09-02 21:05         ` erik quanstrom
2014-09-02 21:50           ` Kurt H Maier
2014-09-02 23:00             ` erik quanstrom
2014-09-02 23:04               ` Bakul Shah
2014-09-02 23:19                 ` erik quanstrom
2014-09-02 23:29                   ` Bakul Shah
2014-09-02 21:10         ` Skip Tavakkolian [this message]
2014-09-02 21:14           ` Steve Simon
2014-09-02 21:27           ` Bakul Shah
2014-09-02 21:43             ` Skip Tavakkolian
2014-09-02 18:36 ` Kurt H Maier
2014-09-02 19:18   ` Steve Simon
2014-09-02 23:34 sl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJSxfm+vDRwVqZGxJK1rDvJnj7AF0VJSW80yMCFxCe2awF8F+w@mail.gmail.com \
    --to=skip.tavakkolian@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).