Archive Page 2

Python – Relative datetime formatting

I wanted a function in Python to get a relative datetime string formatting. For a given datetime object, it should be compared with the current date/time and a relative date/time format should be given as output.

For example, given a date/time lets say (July 2, 2007 7:00 pm) the output should be 7:00 pm Monday, while for October 3, 1980 6:00 am, it should give just 10/03/1980. I googled a lot, but didn’t get any code to copy. So I had to write my own. If anybody needs it from now on, you can take it from here.

#!/usr/bin/env python

import datetime

def getRelativeDateTime(date, now = None): 

    if not now:	now = datetime.now()

    diff = date.date() -­ now.date()

    if diff.days == 0:#Today

        return 'at ' + date.strftime("%I:%M %p")## at 05:45 PM

    elif diff.days == ­1:#Yesterday

        return 'at ' + date.strftime("%I:%M %p") + ' Yesterday'## at 05:45 PM Yesterday

    elif diff.days == 1:#Tomorrow

        return 'at ' + date.strftime("%I:%M %p") + ' Tomorrow'## at 05:45 PM Tomorrow

    elif diff.days < ­7:#Within one week back

        return 'at ' + date.strftime("%I:%M %p %A")## at 05:45 PM Tuesday

    else:

        return 'on ' + date.strftime("%m/%d/%Y")## on 10/03/1980

Ubuntu Feisty Fawn (7.04) and OpenOffice.org

The OpenOffice.org package (2.2.0-1ubuntu3) that comes with Ubuntu Feisty Fawn distribution has some issues especially on the document conversion front. I did not face any problem on my dektop edition installed directly from the feisty fawn dvd. But on the server edition the conversion was taking almost 20x more time. On googling it seemed to be a problem with the java compilation on the OpenOffice package from Ubuntu.

The best and easiest remedy is to uninstall your current OpenOffice.org packages completely and install the latest OpenOffice 2.2.1 from directly from www.openoffice.org. Installation is a bit tricky so I suggest you take a look at this article where the installation is described step by step.

You might have to install msttcorefonts package if you start facing issues with windows fonts once you install OpenOfiice 2.2.1.

OpenOffice as a Document Converter

Though not well known for it, OpenOffice.org can be extended as a doument conversion engine capable of conversion between almost all kind of office documents. OpenOffice.org directly doesn’t support a command-line option, but allows it to be run as a service. An open source tool JodConverter (earlier called JooConverter) provides a wrapper for the OpenOffice.org service and exposes web and command-line interaces to simply convert between the compatible office formats.

Read Full Article by Dmitry Popov at Linux.com

Odondo – The communicator

If anybody wondered about Odondo- The Talking Drum, it is a West African percussion instrument. Used by local tribes in Ghana, it also serves as a communicating device for passing messages to far off places. I guess everyone of us has imagined the talking drum when we read the phantom stories. It is not just imaginary. This hour glass shaped drum dates back centuries and is still popular among the tribes and modern African drummers. This instrument is well known for the pitch variation it can produce that it almost mimics the talk.

The drummer places the drum under one shoulder and beats it with a stick varying the pitch with the pressure from his upper arm. Also called Dondo, Doodo, Donno and so on among different tribes, people used it to pass their messages drumming the name of the recipient, then the sender followed by the message. Isn’t that amazing?

From my childhood I was fascinated towards yet another hour glass shaped instrument Idakka found in Kerala, South India (where I hail from). This instrument shares a lot of similarities with the odondo, for instance the shape, the pitch variation and the style of playing.

Every Journey has a beginning

This is my first real attempt to write something on the net! Though I’ve got some avid blogger friends, my laziness had kept me from starting my own.

The laziness factor inside me has just melted off during last few days when I started looking at blogs seriously. In fact there were plenty of instances recently where I found myself completely depending on blogs before doing something new. Most of them were simple narrations of the bloggers’ experiences. But it surely helps others from going through the same pain over and over. I started feeling it was very selfless of these writers in sharing their personal experiences and knowledge for the benefit of others and I couldn’t keep myself away any more.

This is my first step. Like my friend said, Every journey has a beginning and I dont want to delay it any further.. :)

Here I want to share my views and encounters with computing and music … and may be rarely on life.

« Previous Page