[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead
Tynsoe Projects • View topic - Looking to compare the month of two dates

Looking to compare the month of two dates

Looking to compare the month of two dates

Postby jobbogamer » Tue Jun 08, 2010 9:48 pm

Hi, I'm new to GeekTool, I was wondering if anyone can hit me up with a script to do the following.

I want to have four Geeklets, two showing a month name, one showing today's date and another showing tomorrow's date, ie:

<month-name> <month-name>
<today's-date> <tomorrow's-date>

However, what makes it difficult is I'd like to have it so that the <month-name> on the right only displays text when it's different to the first <month-name>. For instance, if it was the 30th of June today, then the setup would show:

<June> <July>
<30> <1>

But if it were the 4th of June today, it would show:

<June>
<4> <5>

Is there a way to do this, or am I being over-complicated?
jobbogamer
 
Posts: 1
Joined: Tue Jun 08, 2010 9:41 pm

Re: Looking to compare the month of two dates

Postby ybizeul » Sat Jun 19, 2010 2:32 pm

This look ok :
Code: Select all
tom=$(( `date +%s` + 3600 * 24 ))
dtoday=`date +%d`
mtoday=`date +%B`
dtom=`date -r $tom +%d`
mtom=`date -r $tom +%B`

/bin/echo -n $mtoday " "
if [ "$mtoday" != "$mtom" ]
then
        echo $mtom
fi
echo
echo $dtoday $dtom
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm


Return to GeekTool

Who is online

Users browsing this forum: No registered users and 5 guests

cron