Date Image Thing

Author: Joe Maddalone

I want to be trendy, too

For shiggles, I wanted to add a nice little trendy date format to my postings, but everything I found seemed a bit too wordy for me. It always looks like this:

<div class="post-date">
<span class="month">10</span>
<span class="day">04</span>
<span class="year">1977</span>
</div>

This site is dynamically generated, so it wouldn't take too much effort in order to implement such a structure, but I'm stubborn... so here goes

Overprocessed, Nerdy Post Date Image Generation


<%@ Import Namespace="System.Drawing" %>
 <%@ Import Namespace="System.Drawing.Imaging" %>
 <script language="VB" runat="server">
 Sub Page_Load(sender as Object, e as EventArgs)
 dim strDt as string = request.querystring("dt")
 dim strMonth as string = left(MonthName(Month(strDt)),3).ToUpper()
 dim strDay as string = Day(strDt).ToString()
 if strDay.Length=1
 	strDay="0" & strDay
 end if
 dim strYear as string = Year(strDt).ToString()
 
  Dim baseMap as Bitmap = new Bitmap(95, 13)
  '13 cuts it off, which looks cool -- see emersian.com
  Dim myGraphic as Graphics = Graphics.FromImage(baseMap)
  Dim upBrush as SolidBrush = new SolidBrush(Color.black)
  Dim downBrush as SolidBrush = new SolidBrush(Color.steelblue)
  Dim MonthFont as Font = new Font("tahoma", 11,FontStyle.Bold)
  Dim dtFont as Font = new Font("tahoma", 14,FontStyle.Bold)
  myGraphic.FillRectangle(new SolidBrush(Color.white), 0, 0, 100, 25)  
  myGraphic.DrawString(strMonth, MonthFont, upBrush, 0, 0)
  myGraphic.DrawString(strDay, MonthFont, downBrush, 30, 0)
  myGraphic.DrawString(strYear, MonthFont, upBrush, 50, 0)
  myGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias 
  
  Response.ContentType = "image/gif"
  baseMap.Save(Response.OutputStream, ImageFormat.GIF)

  myGraphic.Dispose()
  baseMap.Dispose()
 End Sub
 </script>
%>

Usage

< img src="dt.aspx?dt=DATE STRING HERE" />

If you enjoyed this post Bookmark it at del.icio.us

Comments

Cvlgaiow
7/8/2008 2:16:49 PM Very Good Site <a href=" teen pic ">preteen tgp</a> zyaslv <a href=" teen cartoons ">teenage suicides</a> 8-]]]
Hgnmjhkv
7/8/2008 2:40:36 PM It`s serious <a href=" portfolios russia ">nudism teens</a> 831279 <a href=" dicipline ">teen abortion</a> rkgvr
Satkfrbf
7/8/2008 4:32:57 PM It`s serious <a href=" skateboarding ">teen scholarships</a> lpqgyu <a href=" teen brandi ">teenage hitchhikers</a> >:DDD

Leave a Comment

 

 







LATEST POSTS

Portfolio of the Future Just a random bit of sketching I was doing. Random things this month On my way to the interwebs I recall all I have learned today. CSV Splitter Reinventing the wheel one app at a time. Competetive Data Scraping Not yet an Olympic sport. Date Image Thing GDI+ to overprocess blog post dates!

ADS

MOST POPULAR

Multiple IEs in Windows Firefox Vs. The World Who Is Xperya? ActionScript Form Fields Quick Watermark IE 7 beta 2 standalone Text Link Ads

IP Address Tool Chicago Web Design Free Text Messaging