Ruby for the wrong reason

Hi

A few months ago, I started learning Python - my first language for a
project I want to do (personal) which will involve several facets
including MySql/postgres database and gui frontend I need to create on
windows xp. So I started this in python and I use Eric 4 ide.

At the time I had no knowledge and tossed up between Ruby and Python,
I chose python because I thought it had been around longer so may be
more mature.

So why Ruby now, well honestly my 3rd daughter has been born two days
ago Ruby Jean, why would I program Python when my daughter is Ruby?

My question would Eric4 still be a good choice for Ide in Ruby, code
completion, highlighting(syntax) and debugging would be required in
IDE.

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

My python script to capture date input and check for errors.

import datetime as dt
def ObtainDate():
    isValid=False
    while not isValid:
        userIn = raw_input("Type Date dd/mm/yy: ")
        try: # strptime throws an exception if the input doesn't match
the pattern
            d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
            isValid=True
            print d1, type(d1) # 2003-07-15 00:00:00 <type
'datetime.datetime'>
            "convert datetime object to a 10 character string"
            d2 = str(d1)[:10]
            print d2, type(d2) # 2003-07-15 <type 'str'>
        except:
            print "Try again! dd/mm/yy\n"
    Fname = "data.dat"
    newFname = d2 + Fname
    return newFname
print ObtainDate()

flebber wrote:

Hi

A few months ago, I started learning Python - my first language for a
project I want to do (personal) which will involve several facets
including MySql/postgres database and gui frontend I need to create on
windows xp. So I started this in python and I use Eric 4 ide.

At the time I had no knowledge and tossed up between Ruby and Python,
I chose python because I thought it had been around longer so may be
more mature.

I went through this same process, even tried learning Perl which I disliked, tasted like I chalk in my mouth. Being a C++ developer, Ruby was my natural choice (front runner). Python lost me because I thought it was just stupid to only have indentations to declare code blocks. Other Python users told me I would overcome this. Someone did a good job of trying to sell me Python + Django as the way to go. So even though Ruby was more fun and felt natural to me, I still struggled with what to go with.

In the end I didn't pick Ruby, Ruby picked me. I just when with what felt good to me and then the rest didn't matter what was better.

There are never no wrong reasons, it's better to explore and then go with the flow for what feels good to you, not someone else.

So why Ruby now, well honestly my 3rd daughter has been born two days
ago Ruby Jean, why would I program Python when my daughter is Ruby?

My question would Eric4 still be a good choice for Ide in Ruby, code
completion, highlighting(syntax) and debugging would be required in
IDE.

Someone was capturing the various IDE in a spreadsheet, I don't have that email around...possibly they will reply with the link soon =)

But I suggest you take a look at Aptana, it's got everything you need and it will also allow you to create Rails applications.

Enjoy and save the python for the wife :wink:

···

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

My python script to capture date input and check for errors.

import datetime as dt
def ObtainDate():
    isValid=False
    while not isValid:
        userIn = raw_input("Type Date dd/mm/yy: ")
        try: # strptime throws an exception if the input doesn't match
the pattern
            d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
            isValid=True
            print d1, type(d1) # 2003-07-15 00:00:00 <type
'datetime.datetime'>
            "convert datetime object to a 10 character string"
            d2 = str(d1)[:10]
            print d2, type(d2) # 2003-07-15 <type 'str'>
        except:
            print "Try again! dd/mm/yy\n"
    Fname = "data.dat"
    newFname = d2 + Fname
    return newFname
print ObtainDate()

--
Kind Regards,
Rajinder Yadav

http://DevMentor.org
Do Good ~ Share Freely

flebber wrote:

Hi

A few months ago, I started learning Python - my first language for a
project I want to do (personal) which will involve several facets
including MySql/postgres database and gui frontend I need to create on
windows xp. So I started this in python and I use Eric 4 ide.

At the time I had no knowledge and tossed up between Ruby and Python,
I chose python because I thought it had been around longer so may be
more mature.

So why Ruby now, well honestly my 3rd daughter has been born two days
ago Ruby Jean, why would I program Python when my daughter is Ruby?

My question would Eric4 still be a good choice for Ide in Ruby, code
completion, highlighting(syntax) and debugging would be required in
IDE.

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

My python script to capture date input and check for errors.

import datetime as dt
def ObtainDate():
    isValid=False
    while not isValid:
        userIn = raw_input("Type Date dd/mm/yy: ")
        try: # strptime throws an exception if the input doesn't match
the pattern
            d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
            isValid=True
            print d1, type(d1) # 2003-07-15 00:00:00 <type
'datetime.datetime'>
            "convert datetime object to a 10 character string"
            d2 = str(d1)[:10]
            print d2, type(d2) # 2003-07-15 <type 'str'>
        except:
            print "Try again! dd/mm/yy\n"
    Fname = "data.dat"
    newFname = d2 + Fname
    return newFname
print ObtainDate()

This is a good example for you to investigate on your own. It will
introduce you to ruby's documentation(or lack thereof).

Here's how I would do it in python:

def get_new_fname(fname):
    while True:
        try:
            s = raw_input("Enter a date (dd/mm/yy): ")
            in_format = "%d/%m/%y"
            dt_obj = dt.datetime.strptime(s, in_format)
            break
        except ValueError:
            print "Wrong format! Try again."

    out_format = "%Y-%m-%d"
    prefix = dt_obj.strftime(out_format)

    new_fname = "%s%s" % (prefix, fname)
    return new_fname

name = "data.dat"
new_name = get_new_fname(name)
print new_name

--output:--
2009-10-05data.dat

···

--
Posted via http://www.ruby-forum.com/\.

flebber wrote:

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

No. I think in ruby the code would be almost exactly the same--except
it's significantly harder to figure out in ruby because there is no
documentation about the format specifiers you can use with strftime()
and strptime(). Amazing, huh?

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

ruby and python are in the same state of evolution right now--both are
in the midst of a major version change. In both cases, the newer
versions won't have as many libraries available to them because most
libraries have not yet been rewritten to accommodate the latest version.
So the choice is: go with ruby 1.8.6 and have more libraries available
to you, or go with ruby 1.9.x to learn the latest greatest language
changes. I think most people probably have 1.8.6 and 1.9.x installed
side by side(in python it would be 2.6.x and 3.x). They probably use
1.8.6 for their serious programs, and then they play around with 1.9.x
to learn the new stuff.

···

--
Posted via http://www.ruby-forum.com/\.

If it's a brand-new project, use 1.9.1.

Unless you do something strange, it should be portable backwards to 1.8.7, and
with a few (very small) patches, to 1.8.6.

As others say, not all libraries will be available on 1.9.1, but the vast,
VAST majority are. If you have a choice between two libraries, one which works
on 1.9.1, and one which doesn't, that's a strong hint about which is more
actively maintained.

And all other things equal, 1.9.1 is twice as fast as 1.8.6, so there isn't a
good reason not to use it.

On an existing project, that depends entirely on whether the project has been
ported to 1.9 yet.

The preview version, you could install it side by side and test, to make sure
everything still works. But you generally want to use a stable version -- just
not a stable-as-in-Debian-stable version :wink:

···

On Monday 05 October 2009 10:45:08 pm flebber wrote:

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

And to think, this whole dilemma could have been avoided if you named
her Python.

···

On Mon, Oct 5, 2009 at 11:45 PM, flebber <flebber.crue@gmail.com> wrote:

Hi

A few months ago, I started learning Python - my first language for a
project I want to do (personal) which will involve several facets
including MySql/postgres database and gui frontend I need to create on
windows xp. So I started this in python and I use Eric 4 ide.

At the time I had no knowledge and tossed up between Ruby and Python,
I chose python because I thought it had been around longer so may be
more mature.

So why Ruby now, well honestly my 3rd daughter has been born two days
ago Ruby Jean, why would I program Python when my daughter is Ruby?

My question would Eric4 still be a good choice for Ide in Ruby, code
completion, highlighting(syntax) and debugging would be required in
IDE.

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

My python script to capture date input and check for errors.

import datetime as dt
def ObtainDate():
isValid=False
while not isValid:
userIn = raw_input("Type Date dd/mm/yy: ")
try: # strptime throws an exception if the input doesn't match
the pattern
d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
isValid=True
print d1, type(d1) # 2003-07-15 00:00:00 <type
'datetime.datetime'>
"convert datetime object to a 10 character string"
d2 = str(d1)[:10]
print d2, type(d2) # 2003-07-15 <type 'str'>
except:
print "Try again! dd/mm/yy\n"
Fname = "data.dat"
newFname = d2 + Fname
return newFname
print ObtainDate()

here you go :slight_smile:

if eric4 ends up being a good ruby ide, please add an entry for it

martin

···

On Tue, Oct 6, 2009 at 9:44 AM, Rajinder Yadav <devguy.ca@gmail.com> wrote:

Someone was capturing the various IDE in a spreadsheet, I don't have that
email around...possibly they will reply with the link soon =)

No. I think in ruby the code would be almost exactly the same--except it's significantly harder to figure out in ruby because there is no documentation about the format specifiers you can use with strftime() and strptime(). Amazing, huh?

http://lmgtfy.com/?q=ruby+strftime

Reveals:

http://ruby-doc.org/core/classes/Time.html#M000298

Regards,

Bill

···

From: "7stud --" <bbxx789_05ss@yahoo.com>

Sounds like what I had trouble with (regarding Python) hated the indentations, especially when porting from Python 2 - 3 what a nightmare :smiley:

For an IDE (if you are using OS X) I'd suggest Textmate, it has everything you could possibly want (C, C++, Python, Ruby, Ruby on Rails, PHP, Perl, etc) it costs about £40 ($60 ish) but is well worth it. As for Ruby version, 1.8.7 works great with Rails and is the prefered version. I use 1.8.6 (or .7) on Snow Leopard and the same on Linux I think, though personally, I'd always prefer to go with the most stable and newest version (being 1.9.1).

Regards, Adam

···

--- On Tue, 6/10/09, Rajinder Yadav <devguy.ca@gmail.com> wrote:

From: Rajinder Yadav <devguy.ca@gmail.com>
Subject: Re: Ruby for the wrong reason
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Date: Tuesday, 6 October, 2009, 4:14 AM

flebber wrote:

Hi

A few months ago, I started learning Python - my first language for a
project I want to do (personal) which will involve several facets
including MySql/postgres database and gui frontend I need to create on
windows xp. So I started this in python and I use Eric 4 ide.

At the time I had no knowledge and tossed up between Ruby and Python,
I chose python because I thought it had been around longer so may be
more mature.

I went through this same process, even tried learning Perl which I disliked, tasted like I chalk in my mouth. Being a C++ developer, Ruby was my natural choice (front runner). Python lost me because I thought it was just stupid to only have indentations to declare code blocks. Other Python users told me I would overcome this. Someone did a good job of trying to sell me Python + Django as the way to go. So even though Ruby was more fun and felt natural to me, I still struggled with what to go with.

In the end I didn't pick Ruby, Ruby picked me. I just when with what felt good to me and then the rest didn't matter what was better.

There are never no wrong reasons, it's better to explore and then go with the flow for what feels good to you, not someone else.

So why Ruby now, well honestly my 3rd daughter has been born two days
ago Ruby Jean, why would I program Python when my daughter is Ruby?

My question would Eric4 still be a good choice for Ide in Ruby, code
completion, highlighting(syntax) and debugging would be required in
IDE.

Someone was capturing the various IDE in a spreadsheet, I don't have that email around...possibly they will reply with the link soon =)

But I suggest you take a look at Aptana, it's got everything you need and it will also allow you to create Rails applications.

Enjoy and save the python for the wife :wink:

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

My python script to capture date input and check for errors.

import datetime as dt
def ObtainDate():
isValid=False
while not isValid:
userIn = raw_input("Type Date dd/mm/yy: ")
try: # strptime throws an exception if the input doesn't match
the pattern
d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
isValid=True
print d1, type(d1) # 2003-07-15 00:00:00 <type
'datetime.datetime'>
"convert datetime object to a 10 character string"
d2 = str(d1)[:10]
print d2, type(d2) # 2003-07-15 <type 'str'>
except:
print "Try again! dd/mm/yy\n"
Fname = "data.dat"
newFname = d2 + Fname
return newFname
print ObtainDate()

-- Kind Regards,
Rajinder Yadav

http://DevMentor.org
Do Good ~ Share Freely

Hi --

···

On Tue, 6 Oct 2009, 7stud -- wrote:

flebber wrote:

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

No. I think in ruby the code would be almost exactly the same--except
it's significantly harder to figure out in ruby because there is no
documentation about the format specifiers you can use with strftime()
and strptime(). Amazing, huh?

I usually go straight to the system library documentation for this
stuff, but ri Time#strftime will help you too.

David

--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2\)

Amazingly wrong, yeah:

---------------------------------------------------------- Time#strftime
      time.strftime( string ) => string

···

On Oct 6, 2009, at 1:16 AM, 7stud -- wrote:

No. I think in ruby the code would be almost exactly the same--except
it's significantly harder to figure out in ruby because there is no
documentation about the format specifiers you can use with strftime()
and strptime(). Amazing, huh?

------------------------------------------------------------------------
      Formats _time_ according to the directives in the given format
      string. Any text not listed as a directive will be passed through
      to the output string.

      Format meaning:

        %a - The abbreviated weekday name (``Sun'')
        %A - The full weekday name (``Sunday'')
        %b - The abbreviated month name (``Jan'')
        %B - The full month name (``January'')
        %c - The preferred local date and time representation
        %d - Day of the month (01..31)
        %H - Hour of the day, 24-hour clock (00..23)
        %I - Hour of the day, 12-hour clock (01..12)
        %j - Day of the year (001..366)
        %m - Month of the year (01..12)
        %M - Minute of the hour (00..59)
        %p - Meridian indicator (``AM'' or ``PM'')
        %S - Second of the minute (00..60)
        %U - Week number of the current year,
                starting with the first Sunday as the first
                day of the first week (00..53)
        %W - Week number of the current year,
                starting with the first Monday as the first
                day of the first week (00..53)
        %w - Day of the week (Sunday is 0, 0..6)
        %x - Preferred representation for the date alone, no time
        %X - Preferred representation for the time alone, no date
        %y - Year without a century (00..99)
        %Y - Year with century
        %Z - Time zone name
        %% - Literal ``%'' character

         t = Time.now
         t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
         t.strftime("at %I:%M%p") #=> "at 08:56AM"

James Edward Gray II

As of sometime recently, there were reports of some Rails stuff not working
on it, which might be a good reason.

-s

···

On 2009-10-06, David Masover <ninja@slaphack.com> wrote:

And all other things equal, 1.9.1 is twice as fast as 1.8.6, so there isn't a
good reason not to use it.

--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
| Seebs.Net <-- lawsuits, religion, and funny pictures
Fair game (Scientology) - Wikipedia <-- get educated!

flebber wrote:

Secondly I found capturing the date input from a console in python to
be a little long winded, below is the script I wrote in python would
this be significantly easier in Ruby.

No. I think in ruby the code would be almost exactly the same--except it's significantly harder to figure out in ruby because there is no documentation about the format specifiers you can use with strftime() and strptime(). Amazing, huh?

It's not very good to find but what about this?

Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
of 1.9.2?

ruby and python are in the same state of evolution right now--both are in the midst of a major version change. In both cases, the newer versions won't have as many libraries available to them because most libraries have not yet been rewritten to accommodate the latest version. So the choice is: go with ruby 1.8.6 and have more libraries available to you, or go with ruby 1.9.x to learn the latest greatest language changes. I think most people probably have 1.8.6 and 1.9.x installed side by side(in python it would be 2.6.x and 3.x). They probably use 1.8.6 for their serious programs, and then they play around with 1.9.x to learn the new stuff.

I have both installed but use only 1.9 simply because it is significantly faster and also because the new feature set seems better to me. Since I am not using too many non standard libraries (and gems) the library lag is not an issue for me.

Kind regards

  robert

···

On 10/06/2009 08:16 AM, 7stud -- wrote:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Zachary Carter wrote:

And to think, this whole dilemma could have been avoided if you named
her Python.

lol.
:slight_smile:
:slight_smile:

···

--
Posted via http://www.ruby-forum.com/\.

David Masover:

Which version of Ruby should I use 1.8.6,
1.9.1 or a preview version of 1.9.2?

If it's a brand-new project, use 1.9.1.

I fully agree. I write all of my new stuff in Ruby 1.9.

Unless you do something strange, it should be portable backwards
to 1.8.7, and with a few (very small) patches, to 1.8.6.

And you might find the backports gem *very* useful
(as I have): GitHub - marcandre/backports: The latest features of Ruby backported to older versions.

As others say, not all libraries will be available
on 1.9.1, but the vast, VAST majority are.

Also, you might find http://isitruby19.com/ useful.

If you have a choice between two libraries, one which works on 1.9.1,
and one which doesn't, that's a strong hint about which is more
actively maintained.

+1 :slight_smile:

And all other things equal, 1.9.1 is twice as fast
as 1.8.6, so there isn't a good reason not to use it.

I do a lot number crunching in my PhD code and 1.9 is
almost exactly *three* times faster than 1.8 for me.

— Shot

···

On Monday 05 October 2009 10:45:08 pm flebber wrote:

--
Diaries of Sapir and Whorf Reveal Fears that They Didn’t Truly
Articulate the Spirit of Hypothesis [Patently False]

So If I use version 1.8.6 and later want to update my project to the
1.9 series would this be a hard conversion?

···

On Oct 6, 7:49 pm, Adam Bilbrough <adambilbro...@rocketmail.com> wrote:

Sounds like what I had trouble with (regarding Python) hated the indentations, especially when porting from Python 2 - 3 what a nightmare :smiley:

For an IDE (if you are using OS X) I'd suggest Textmate, it has everything you could possibly want (C, C++, Python, Ruby, Ruby on Rails, PHP, Perl, etc) it costs about £40 ($60 ish) but is well worth it. As for Ruby version, 1.8.7 works great with Rails and is the prefered version. I use 1.86 (or .7) on Snow Leopard and the same on Linux I think, though personally, I'd always prefer to go with the most stable and newest version (being 1.9.1).

Regards, Adam

--- On Tue, 6/10/09, Rajinder Yadav <devguy...@gmail.com> wrote:

From: Rajinder Yadav <devguy...@gmail.com>
Subject: Re: Ruby for the wrong reason
To: "ruby-talk ML" <ruby-t...@ruby-lang.org>
Date: Tuesday, 6 October, 2009, 4:14 AM

flebber wrote:
> Hi

> A few months ago, I started learning Python - my first language for a
> project I want to do (personal) which will involve several facets
> including MySql/postgres database and gui frontend I need to create on
> windows xp. So I started this in python and I use Eric 4 ide.

> At the time I had no knowledge and tossed up between Ruby and Python,
> I chose python because I thought it had been around longer so may be
> more mature.

I went through this same process, even tried learning Perl which I disliked, tasted like I chalk in my mouth. Being a C++ developer, Ruby was my natural choice (front runner). Python lost me because I thought it was just stupid to only have indentations to declare code blocks. Other Python users told me I would overcome this. Someone did a good job of trying to sell me Python + Django as the way to go. So even though Ruby was more fun and felt natural to me, I still struggled with what to go with.

In the end I didn't pick Ruby, Ruby picked me. I just when with what felt good to me and then the rest didn't matter what was better.

There are never no wrong reasons, it's better to explore and then go with the flow for what feels good to you, not someone else.

> So why Ruby now, well honestly my 3rd daughter has been born two days
> ago Ruby Jean, why would I program Python when my daughter is Ruby?

> My question would Eric4 still be a good choice for Ide in Ruby, code
> completion, highlighting(syntax) and debugging would be required in
> IDE.

Someone was capturing the various IDE in a spreadsheet, I don't have that email around...possibly they will reply with the link soon =)

But I suggest you take a look at Aptana, it's got everything you need and it will also allow you to create Rails applications.

http://aptana.com

Enjoy and save the python for the wife :wink:

> Secondly I found capturing the date input from a console in python to
> be a little long winded, below is the script I wrote in python would
> this be significantly easier in Ruby.

> Which version of Ruby should I use 1.8.6, 1.9.1 or a preview version
> of 1.9.2?

> My python script to capture date input and check for errors.

> import datetime as dt
> def ObtainDate():
> isValid=False
> while not isValid:
> userIn = raw_input("Type Date dd/mm/yy: ")
> try: # strptime throws an exception if the input doesn't match
> the pattern
> d1 = dt.datetime.strptime(userIn, "%d/%m/%y")
> isValid=True
> print d1, type(d1) # 2003-07-15 00:00:00 <type
> 'datetime.datetime'>
> "convert datetime object to a 10 character string"
> d2 = str(d1)[:10]
> print d2, type(d2) # 2003-07-15 <type 'str'>
> except:
> print "Try again! dd/mm/yy\n"
> Fname = "data.dat"
> newFname = d2 + Fname
> return newFname
> print ObtainDate()

-- Kind Regards,
Rajinder Yadav

http://DevMentor.org
Do Good ~ Share Freely

If anyone is curious where the information James provided can be found:

http://lmgtfy.com/?q=Ruby+strftime&l=1

···

On Tue, Oct 6, 2009 at 6:54 AM, James Edward Gray II <james@graysoftinc.com>wrote:

On Oct 6, 2009, at 1:16 AM, 7stud -- wrote:

No. I think in ruby the code would be almost exactly the same--except

it's significantly harder to figure out in ruby because there is no
documentation about the format specifiers you can use with strftime()
and strptime(). Amazing, huh?

Amazingly wrong, yeah:

---------------------------------------------------------- Time#strftime
    time.strftime( string ) => string
------------------------------------------------------------------------
    Formats _time_ according to the directives in the given format
    string. Any text not listed as a directive will be passed through
    to the output string.

    Format meaning:

      %a - The abbreviated weekday name (``Sun'')
      %A - The full weekday name (``Sunday'')
      %b - The abbreviated month name (``Jan'')
      %B - The full month name (``January'')
      %c - The preferred local date and time representation
      %d - Day of the month (01..31)
      %H - Hour of the day, 24-hour clock (00..23)
      %I - Hour of the day, 12-hour clock (01..12)
      %j - Day of the year (001..366)
      %m - Month of the year (01..12)
      %M - Minute of the hour (00..59)
      %p - Meridian indicator (``AM'' or ``PM'')
      %S - Second of the minute (00..60)
      %U - Week number of the current year,
              starting with the first Sunday as the first
              day of the first week (00..53)
      %W - Week number of the current year,
              starting with the first Monday as the first
              day of the first week (00..53)
      %w - Day of the week (Sunday is 0, 0..6)
      %x - Preferred representation for the date alone, no time
      %X - Preferred representation for the time alone, no date
      %y - Year without a century (00..99)
      %Y - Year with century
      %Z - Time zone name
      %% - Literal ``%'' character

       t = Time.now
       t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
       t.strftime("at %I:%M%p") #=> "at 08:56AM"

James Edward Gray II

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can’t hear a word you’re saying."

-Greg Graffin (Bad Religion)

James Edward Gray II wrote:

No. I think in ruby the code would be almost exactly the same--except
it's significantly harder to figure out in ruby because there is no
documentation about the format specifiers you can use with strftime()
and strptime(). Amazing, huh?

Amazingly wrong, yeah:

Not at all:

1) $ri Date::strptime

--------------------------------------------------------- Date::strptime

···

On Oct 6, 2009, at 1:16 AM, 7stud -- wrote:

     Date::strptime(str='-4712-01-01', fmt='%F', sg=ITALY)
------------------------------------------------------------------------
     Create a new Date object by parsing from a String according to a
     specified format.

     +str+ is a String holding a date representation. +fmt+ is the
     format that the date is in. See date/format.rb for details on
     supported formats.

     The default +str+ is '-4712-01-01', and the default +fmt+ is '%F',
     which means Year-Month-Day_of_Month. This gives Julian Day Number
     day 0.

     +sg+ specifies the Day of Calendar Reform.

     An ArgumentError will be raised if +str+ cannot be parsed.
-----------------------------

Good luck finding and then digging through the **source code** of
format.rb to locate anything on the format specifiers.

2) $ri Date#strftime

---------------------------------------------------------- Date#strftime
     strftime(fmt='%F')
------------------------------------------------------------------------
     (no description...)

And from the official Standard Library Documentation for 'date':

1)
strptime(str='-4712-01-01', fmt='%F', sg=ITALY)
----------------------------------------

Create a new Date object by parsing from a String according to a
specified format.

str is a String holding a date representation. fmt is the format that
the date is in. See date/format.rb for details on supported formats.

The default str is ’-4712-01-01’, and the default fmt is ’%F’, which
means Year-Month-Day_of_Month. This gives Julian Day Number day 0.

sg specifies the Day of Calendar Reform.

An ArgumentError will be raised if str cannot be parsed.

2)
strftime(fmt='%F')
--------------
[Source]

That last one is a real doozy--and quite typical of ruby Standard
Library documentation.

--
Posted via http://www.ruby-forum.com/\.

Which Rails stuff?
Especially considering Rails officially supports 1.9, I thought.

···

On Tuesday 06 October 2009 01:00:05 pm Seebs wrote:

On 2009-10-06, David Masover <ninja@slaphack.com> wrote:
> And all other things equal, 1.9.1 is twice as fast as 1.8.6, so there
> isn't a good reason not to use it.

As of sometime recently, there were reports of some Rails stuff not working
on it, which might be a good reason.

flebber wrote:

To: "ruby-talk ML" <ruby-t...@ruby-lang.org>
> At the time I had no knowledge and tossed up between Ruby and Python,

> this be significantly easier in Ruby.
>� � � ���userIn = raw_input("Type Date dd/mm/yy: ")
>� � � � � ���print "Try again! dd/mm/yy\n"
>� ���Fname = "data.dat"
>� ���newFname = d2 + Fname
>� ���return newFname
> print ObtainDate()

-- Kind Regards,
Rajinder Yadav

http://DevMentor.org
Do Good ~ Share Freely

So If I use version 1.8.6 and later want to update my project to the
1.9 series would this be a hard conversion?

For Ruby, no. Tt has no specific indentations to follow (within reason)
and the only things that have changed as far as I know (been a while
since I read the release docs) 1.9.1 adds some new functionality to Ruby
but doesn't change the syntax (like Python 2 - 3 did).
With my program I was working on, I was using 1.9.1 (on my old linux
distro) and also running it on my Mac (1.8.7), so as far as the scope of
my program was concerned, the versions were universally capable of
running on either system with zero changes.

Hope this helps!

···

On Oct 6, 7:49�pm, Adam Bilbrough <adambilbro...@rocketmail.com> > wrote:

--
Posted via http://www.ruby-forum.com/\.