Archive

Archive for July, 2009

Days between two dates

Just a quick python function to calculate the days between two dates. It is really simple and easy :)

import datetime

def date_diff_days(from_date=datetime.date.today(),to_date=datetime.date.today() ):
    return (to_date - from_date).days

And an example to use it:

date1 = datetime.date(2009, 03, 26) 
date2 = datetime.date(2009, 07, 25) 

print date_diff_days( date1, date2 )

That’s it :)

Categories: Example, Python, Source code Tags: ,

Absolute positioning and z-index in Internet Explorer 6

During my work I bumped into a silly little problem. Basically IE6 wouldn’t position one of the HTML elements correctly where as IE7 and the rest of the browsers I test with (Firefox, Safari) do.

I googled around a lot to find the solution and an explanation to the problem. Below are my findings.

The problem

<div class="container">
<h1><span>title</span></h1>
<img src="/someimage.jpg" alt="" /></div>

We want to position the <h1> element above the image. We do this by absolutely positioning it. We set position: relative for the container class and position: absolute for the <h1> tag. In firefox, safari and even in IE7 this works and positions the element as we want, but not in IE6.
Read more…

Follow

Get every new post delivered to your Inbox.