[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

get datetime object

Junkone

4/4/2008 5:31:00 PM

how to convert the string in this format ="Monday April, 3, 2006 10:34
AM" into a datetime object. When i use Date.parse, i lose the time on
it. when i use ParseDate.parsedate(d)
i get only a array. any help is appreciated.


E:\TradingTools\CODE>irb
irb(main):001:0> d="Monday April, 3, 2006 10:34 AM"
=> "Monday April, 3, 2006 10:34 AM"
irb(main):002:0> Date.parse(d)
=> #<Date: 4907657/2,0,2299161>

irb(main):004:0> pd=ParseDate.parsedate(d)
=> [2006, 4, 3, 10, 34, nil, nil, 1]
3 Answers

Justin Collins

4/4/2008 5:56:00 PM

0

Junkone wrote:
> how to convert the string in this format ="Monday April, 3, 2006 10:34
> AM" into a datetime object. When i use Date.parse, i lose the time on
> it. when i use ParseDate.parsedate(d)
> i get only a array. any help is appreciated.
>
>
> E:\TradingTools\CODE>irb
> irb(main):001:0> d="Monday April, 3, 2006 10:34 AM"
> => "Monday April, 3, 2006 10:34 AM"
> irb(main):002:0> Date.parse(d)
> => #<Date: 4907657/2,0,2299161>
>
> irb(main):004:0> pd=ParseDate.parsedate(d)
> => [2006, 4, 3, 10, 34, nil, nil, 1]
>
>
If you want a DateTime object, then you need to use that, not Date.

irb(main):001:0> require 'date'
=> true
irb(main):002:0> date = DateTime.parse("Monday April, 3, 2006 10:34 AM")
=> #<DateTime: 1766756837/720,0,2299161>
irb(main):003:0> date.strftime
=> "2006-04-03T10:34:00+00:00"


-Justin

Junkone

4/4/2008 6:44:00 PM

0

On Apr 4, 1:56 pm, Justin Collins <justincoll...@ucla.edu> wrote:
> Junkone wrote:
> > how to convert the string in this format ="Monday April, 3, 2006 10:34
> > AM" into a datetime object. When i use Date.parse, i lose the time on
> > it. when i use ParseDate.parsedate(d)
> > i get only a array. any help is appreciated.
>
> > E:\TradingTools\CODE>irb
> > irb(main):001:0> d="Monday April, 3, 2006 10:34 AM"
> > => "Monday April, 3, 2006 10:34 AM"
> > irb(main):002:0> Date.parse(d)
> > => #<Date: 4907657/2,0,2299161>
>
> > irb(main):004:0> pd=ParseDate.parsedate(d)
> > => [2006, 4, 3, 10, 34, nil, nil, 1]
>
> If you want a DateTime object, then you need to use that, not Date.
>
> irb(main):001:0> require 'date'
> => true
> irb(main):002:0> date = DateTime.parse("Monday April, 3, 2006 10:34 AM")
> => #<DateTime: 1766756837/720,0,2299161>
> irb(main):003:0> date.strftime
> => "2006-04-03T10:34:00+00:00"
>
> -Justin- Hide quoted text -
>
> - Show quoted text -

thanks. it works

PL

5/2/2011 5:22:00 PM

0

On 2/05/2011 18:46, CubaFAQ wrote:
(snip)
> Dan

that is indeed Dan Christensen.

Dan posts here under these names:
- Dan Christensen
- Cubafaq (with a site called issues and answers see his link)
- DCproof with the site: http://www.d...

> Visit my CUBA: Issues& Answers website at its new home:
> http://www3.sympatico.ca/danchr..........

Dan Christensen again.

> (The original CubaFAQ website. Don't be fooled by PL's cheap
> imitations.)

there are no imitations, Dan Christensen.
just your lies.
The site owned Cubafaq, a name this person has been using for years.
http://cubafaq.i...

EXPOSING DAN CHRISTENSEN'S PERSONAL SLANDEROUS ATTACK ON ME AND CUBAFAQ

Each of us (unknowingly) influences the ads wee see online.
We decide which sites we visit. They provide the contextual element of
the ad selection.
Past browsing behavior as laid down in cookies and other tracking
systems is also a determining factor is the selection of ads: the
historical element.

The site owner as a rule selects the standard "image and text" ad, the
color and the size.
The image or text ad shown is a combination of "contextual" elements
(what is on the site - in the case of Cubafaq's site: news about Cuba)
and "historical" elements that are based on your browsing behavior as
reflected in your cookies.

For example: a man that visits lots of sites on fishing will be targeted
with information on fishing trips / opportunities in Canada when he goes
to a Canadian travel site.

A person with a "historical" record (or open sites of a certain
nature)is more likely to get certain ads than others.
It is of course not a perfect system, but Google has a solid reputation
for its ads strategies and techniques. Some people are clearly more
likely to be targeted with a certain type of ads than others who have no
supporting historical base.

So blaming others for content provided to you by Google Adsense based on
your choices of current and past visits of sites is hypocrite Dan
Christensen.

Do you now understand why you ridiculed yourself here again, Dan.
Don't blame others for your debacle: you slanderous campaign of personal
attacks brought you this. Your continued attacks will bring you more
ridicule.

See:

"A while back, Google AdSense migrated from purely contextual
advertising to historical advertising. I didn't notice until I visited
the Economist web site, once. Since then, it feels like 50% of the web
is trying to get me to subscribe!

The difference is clearly illustrated on the screen capture. On the
left, page visited using Google Chrome, my regular browser on my home
computer. On the right, IE 9 beta, which I rarely use.

There are a couple of problems with the historical, cookie based
advertising. The main one is that I already subscribe to both The
Economist and Netflix! The second is if I click on The Economist one, it
bring me to an offer for Americans only!"

http://altavistagoogle.blogspot.com/2011/01/impact-of-cookies-on-google-ad...

Some advice to all:
- clean your cookies and browsing history. Note that that will remove
the "visited site list" in your browser and may force you to log in
again on certain sites.
- use safe connections while browsing like https://encrypted.g...
Lots of add-ons are available to protect your privacy

The two above will suffice for most people. Beyond that there are a
series of other others, but I don't want to show my hand too much.

Having been the target of numerous - both "cyber" and "verbal" - attacks
I kind of learned to protect myself.
Let's see what Dan Christensen's next attack brings.
If none this post closes that matter for me.

PS: You are such a pompous asshole Dan Christensen. .