
import Data.Time.LocalTime
import Data.Time.Format
import System.Locale
now :: Maybe LocalTime -- Change this to get different types of values
(days, etc).
now = parseTime defaultTimeLocale "%F" "2011-07-11"
main = putStrLn $ case now of
Nothing -> "Failed Parse"
Just x -> (formatTime defaultTimeLocale "%F" x)
On Sat, Jul 9, 2011 at 12:33 PM, Rolf Hanson
Hi, I'm trying to iterate over a range of dates and print them out. Here's how I am doing it in Ruby:
'require 'date'
now = Date.parse('2011-07-11') end_date = Date.parse('2011-12-31')
(now..end_date).each do |d| # print out a date that looks like: # Monday, July 11, 2011 puts "#{d.strftime('%A, %B %d, %Y')}" end
I've been looking at the docs for Data.Time.Format and Data.Time.Calendar and am a bit puzzled at where to begin. Anyone have ideas? I've not found many (any?) examples of time and date manipulation in Haskell.
RW _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners