[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

DateTime in UTC

bcparanj@gmail.com

8/22/2008 8:42:00 AM

How do I extract the hour and minutes in UTC from a DateTime object? I
have looked at the Ruby cookbook and Ruby Way with no luck.

When I try:

>> d = DateTime.new(2008,8, 20, 12, 15)
=> Wed, 20 Aug 2008 12:15:00 +0000
>> d.zone
=> "+00:00"
>> d.min
=> 15
>> d.hour
=> 12

The result is not the same as executing the following javascript:

// Converts the given time into UTC, returns this in a string
function getUTCDateString(y,m,d,h,min) {
var timeObj = new Date(y,m-1,d,h,min);
var dateStr = "" + timeObj.getUTCFullYear();
dateStr += stringPad(timeObj.getUTCMonth()+1);
dateStr += stringPad(timeObj.getUTCDate());
dateStr += "T" + stringPad(timeObj.getUTCHours());
dateStr += stringPad(timeObj.getUTCMinutes()) + "00Z";
return dateStr;
}

TIA.
9 Answers

Axel Etzold

8/22/2008 8:55:00 AM

0

> How do I extract the hour and minutes in UTC from a DateTime object? I
> have looked at the Ruby cookbook and Ruby Way with no luck.
>
> When I try:
>
> >> d = DateTime.new(2008,8, 20, 12, 15)
> => Wed, 20 Aug 2008 12:15:00 +0000
> >> d.zone
> => "+00:00"
> >> d.min
> => 15
> >> d.hour
> => 12

What behaviour are you expecting ?

Best regards,

Axel
--
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/m...

Peña, Botp

8/22/2008 9:12:00 AM

0

From: bcparanj@gmail.com [mailto:bcparanj@gmail.com]=20
# >> d =3D DateTime.new(2008,8, 20, 12, 15)
# =3D> Wed, 20 Aug 2008 12:15:00 +0000

compare,

> d =3D Time.utc(2008,8, 20, 12, 15)
=3D> Wed Aug 20 12:15:00 UTC 2008

bcparanj@gmail.com

8/22/2008 6:31:00 PM

0

On Aug 22, 1:55 am, Axel Etzold <AEtz...@gmx.de> wrote:
> > How do I extract the hour and minutes in UTC from a DateTime object? I
> > have looked at the Ruby cookbook and Ruby Way with no luck.
>
> > When I try:
>
> > >> d = DateTime.new(2008,8, 20, 12, 15)
> > => Wed, 20 Aug 2008 12:15:00 +0000
> > >> d.zone
> > => "+00:00"
> > >> d.min
> > => 15
> > >> d.hour
> > => 12
>
> What behaviour are you expecting ?
>
> Best regards,
>
> Axel
> --
> Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
> Der Eine für Alle:http://www.gmx.net/de/go/m...

I created the following list of the expected behavior from
http://www.google.com/googlecalendar/event_publisher_...

Hour : Value in UTC
1 : 0900
2 : 1000
3 : 1100
4 : 1200
5 : 1300
6 : 1400
7 : 1500
8 : 1600
9 : 1700
10 : 1800
11 : 1900
12 : 2000
13 : 2100
14 : 2200
15 : 2300
16 : 0000
17 : 0100
18 : 0200
19 : 0300
20 : 0400
21 : 0500
22 : 0600
23 : 0700
00 : 0800

Hour:Mins - UTC value
00:00 - 0800
00:15 - 0815
00:30 - 0830
00:45 - 0845

It seems to be using some offset to convert the given date to UTC
values. I don't know how to convert a given hour to its UTC value.

bcparanj@gmail.com

8/22/2008 6:34:00 PM

0


> I created the following list of the expected behavior fromhttp://www.google.com/googlecalendar/event_publisher_...
>
> Hour : Value in UTC
> 1  : 0900
> 2  : 1000
> 3  : 1100
> 4  : 1200
> 5  : 1300
> 6  : 1400
> 7  : 1500
> 8  : 1600
> 9  : 1700
> 10 : 1800
> 11 : 1900
> 12 : 2000
> 13 : 2100
> 14 : 2200
> 15 : 2300
> 16 : 0000
> 17 : 0100
> 18 : 0200
> 19 : 0300
> 20 : 0400
> 21 : 0500
> 22 : 0600
> 23 : 0700
> 00 : 0800
>
> Hour:Mins - UTC value
> 00:00 - 0800
> 00:15 - 0815
> 00:30 - 0830
> 00:45 - 0845
>
> It seems to be using some offset to convert the given date to UTC
> values. I don't know how to convert a given hour to its UTC value.

Sorry, I meant converting from Date or DateTime object to UTC values
similar to above sample data for hours and mins. Thanks.

Axel Etzold

8/22/2008 6:52:00 PM

0


-------- Original-Nachricht --------
> Datum: Sat, 23 Aug 2008 03:31:10 +0900
> Von: "bcparanj@gmail.com" <bcparanj@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: DateTime in UTC

>
> > I created the following list of the expected behavior
> fromhttp://www.google.com/googlecalendar/event_publisher_...
> >
> > Hour : Value in UTC
> > 1  : 0900
> > 2  : 1000
> > 3  : 1100
> > 4  : 1200
> > 5  : 1300
> > 6  : 1400
> > 7  : 1500
> > 8  : 1600
> > 9  : 1700
> > 10 : 1800
> > 11 : 1900
> > 12 : 2000
> > 13 : 2100
> > 14 : 2200
> > 15 : 2300
> > 16 : 0000
> > 17 : 0100
> > 18 : 0200
> > 19 : 0300
> > 20 : 0400
> > 21 : 0500
> > 22 : 0600
> > 23 : 0700
> > 00 : 0800
> >
> > Hour:Mins - UTC value
> > 00:00 - 0800
> > 00:15 - 0815
> > 00:30 - 0830
> > 00:45 - 0845
> >
> > It seems to be using some offset to convert the given date to UTC
> > values. I don't know how to convert a given hour to its UTC value.
>
> Sorry, I meant converting from Date or DateTime object to UTC values
> similar to above sample data for hours and mins. Thanks.

One of the two times is your local time zone (if it's +08:00, you'll most probably be in China, Malaysia, Singapore,
the Philippines, somepart of central Indonesia or in Western Australia.)
There is a database collecting time zone details, including daylight savings time, by Mr. Olson,
and there's a Ruby library to convert from and into UTC ,which is basically the time zone of
England, disregarding daylight savings time there.

Look here :


http://tzinfo.ruby...
http://www.worldtimezone.com/in... (the map has nice zoom-in properties)

Best regards,

Axel

--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/s...

Rick DeNatale

8/22/2008 10:04:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, Aug 22, 2008 at 2:52 PM, Axel Etzold <AEtzold@gmx.de> wrote:

>
> -------- Original-Nachricht --------
> > Datum: Sat, 23 Aug 2008 03:31:10 +0900
> > Von: "bcparanj@gmail.com" <bcparanj@gmail.com>
> > An: ruby-talk@ruby-lang.org
> > Betreff: Re: DateTime in UTC
>
> >
> > > I created the following list of the expected behavior
> > fromhttp://www.google.com/googlecalendar/event_publisher_...
> > >
> > > Hour : Value in UTC
> > > 1 : 0900
> > > 2 : 1000
> > > 3 : 1100
> > > 4 : 1200
> > > 5 : 1300
> > > 6 : 1400
> > > 7 : 1500
> > > 8 : 1600
> > > 9 : 1700
> > > 10 : 1800
> > > 11 : 1900
> > > 12 : 2000
> > > 13 : 2100
> > > 14 : 2200
> > > 15 : 2300
> > > 16 : 0000
> > > 17 : 0100
> > > 18 : 0200
> > > 19 : 0300
> > > 20 : 0400
> > > 21 : 0500
> > > 22 : 0600
> > > 23 : 0700
> > > 00 : 0800
> > >
> > > Hour:Mins - UTC value
> > > 00:00 - 0800
> > > 00:15 - 0815
> > > 00:30 - 0830
> > > 00:45 - 0845
> > >
> > > It seems to be using some offset to convert the given date to UTC
> > > values. I don't know how to convert a given hour to its UTC value.
> >
> > Sorry, I meant converting from Date or DateTime object to UTC values
> > similar to above sample data for hours and mins. Thanks.
>
> One of the two times is your local time zone (if it's +08:00, you'll most
> probably be in China, Malaysia, Singapore,
> the Philippines, somepart of central Indonesia or in Western Australia.)
> There is a database collecting time zone details, including daylight
> savings time, by Mr. Olson,
> and there's a Ruby library to convert from and into UTC ,which is basically
> the time zone of
> England, disregarding daylight savings time there.
>
> Look here :
>
>
> http://tzinfo.ruby...
> http://www.worldtimezone.com/in... (the map has nice zoom-in
> properties)
>
> Best regards,
>
>
And for most timezones, the utc offset depends also on the full time, since
it is different during the period, if any, for which daylight saving time is
observed for the particular timezone.


The TZinfo gem can be used to handle this, once you dig in and understand
it.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

bcparanj@gmail.com

8/22/2008 10:58:00 PM

0

On Aug 22, 3:04 pm, Rick DeNatale <rick.denat...@gmail.com> wrote:
> [Note:  parts of this message were removed to make it a legal post.]
>
>
>
> On Fri, Aug 22, 2008 at 2:52 PM, Axel Etzold <AEtz...@gmx.de> wrote:
>
> > -------- Original-Nachricht --------
> > > Datum: Sat, 23 Aug 2008 03:31:10 +0900
> > > Von: "bcpar...@gmail.com" <bcpar...@gmail.com>
> > > An: ruby-t...@ruby-lang.org
> > > Betreff: Re: DateTime in UTC
>
> > > > I created the following list of the expected behavior
> > > fromhttp://www.google.com/googlecalendar/event_publisher_...
>
> > > > Hour : Value in UTC
> > > > 1  : 0900
> > > > 2  : 1000
> > > > 3  : 1100
> > > > 4  : 1200
> > > > 5  : 1300
> > > > 6  : 1400
> > > > 7  : 1500
> > > > 8  : 1600
> > > > 9  : 1700
> > > > 10 : 1800
> > > > 11 : 1900
> > > > 12 : 2000
> > > > 13 : 2100
> > > > 14 : 2200
> > > > 15 : 2300
> > > > 16 : 0000
> > > > 17 : 0100
> > > > 18 : 0200
> > > > 19 : 0300
> > > > 20 : 0400
> > > > 21 : 0500
> > > > 22 : 0600
> > > > 23 : 0700
> > > > 00 : 0800
>
> > > > Hour:Mins - UTC value
> > > > 00:00 - 0800
> > > > 00:15 - 0815
> > > > 00:30 - 0830
> > > > 00:45 - 0845
>
> > > > It seems to be using some offset to convert the given date to UTC
> > > > values. I don't know how to convert a given hour to its UTC value.
>
> > > Sorry, I meant converting from Date or DateTime object to UTC values
> > > similar to above sample data for hours and mins. Thanks.
>
> > One of the two times is your local time zone (if it's +08:00, you'll most
> > probably be in China, Malaysia, Singapore,
> > the Philippines, somepart of central Indonesia  or in Western Australia.)
> > There is a database collecting time zone details, including daylight
> > savings time, by Mr. Olson,
> > and there's a Ruby library to convert from and into UTC ,which is basically
> > the time zone of
> > England, disregarding daylight savings time there.
>
> > Look here :
>
> >http://tzinfo.ruby...
> >http://www.worldtimezone.com/index24....(the map has nice zoom-in
> > properties)
>
> > Best regards,
>
> And for most timezones, the utc offset depends also on the full time, since
> it is different during the period, if any, for which daylight saving time is
> observed for the particular timezone.
>
> The TZinfo gem can be used to handle this, once you dig in and understand
> it.
>
> --
> Rick DeNatale
>
> My blog on Rubyhttp://talklikeaduck.denh...

Actually, this is for a Rails project. Will the Rails 2.1 help in this
case?

Axel Etzold

8/23/2008 9:30:00 AM

0


-------- Original-Nachricht --------
> Datum: Sat, 23 Aug 2008 07:56:11 +0900
> Von: "bcparanj@gmail.com" <bcparanj@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: DateTime in UTC

> On Aug 22, 3:04 pm, Rick DeNatale <rick.denat...@gmail.com> wrote:
> > [Note:  parts of this message were removed to make it a legal post.]
> >
> >
> >
> > On Fri, Aug 22, 2008 at 2:52 PM, Axel Etzold <AEtz...@gmx.de> wrote:
> >
> > > -------- Original-Nachricht --------
> > > > Datum: Sat, 23 Aug 2008 03:31:10 +0900
> > > > Von: "bcpar...@gmail.com" <bcpar...@gmail.com>
> > > > An: ruby-t...@ruby-lang.org
> > > > Betreff: Re: DateTime in UTC
> >
> > > > > I created the following list of the expected behavior
> > > > fromhttp://www.google.com/googlecalendar/event_publisher_...
> >
> > > > > Hour : Value in UTC
> > > > > 1  : 0900
> > > > > 2  : 1000
> > > > > 3  : 1100
> > > > > 4  : 1200
> > > > > 5  : 1300
> > > > > 6  : 1400
> > > > > 7  : 1500
> > > > > 8  : 1600
> > > > > 9  : 1700
> > > > > 10 : 1800
> > > > > 11 : 1900
> > > > > 12 : 2000
> > > > > 13 : 2100
> > > > > 14 : 2200
> > > > > 15 : 2300
> > > > > 16 : 0000
> > > > > 17 : 0100
> > > > > 18 : 0200
> > > > > 19 : 0300
> > > > > 20 : 0400
> > > > > 21 : 0500
> > > > > 22 : 0600
> > > > > 23 : 0700
> > > > > 00 : 0800
> >
> > > > > Hour:Mins - UTC value
> > > > > 00:00 - 0800
> > > > > 00:15 - 0815
> > > > > 00:30 - 0830
> > > > > 00:45 - 0845
> >
> > > > > It seems to be using some offset to convert the given date to UTC
> > > > > values. I don't know how to convert a given hour to its UTC value.
> >
> > > > Sorry, I meant converting from Date or DateTime object to UTC values
> > > > similar to above sample data for hours and mins. Thanks.
> >
> > > One of the two times is your local time zone (if it's +08:00, you'll
> most
> > > probably be in China, Malaysia, Singapore,
> > > the Philippines, somepart of central Indonesia  or in Western
> Australia.)
> > > There is a database collecting time zone details, including daylight
> > > savings time, by Mr. Olson,
> > > and there's a Ruby library to convert from and into UTC ,which is
> basically
> > > the time zone of
> > > England, disregarding daylight savings time there.
> >
> > > Look here :
> >
> > >http://tzinfo.ruby...
> > >http://www.worldtimezone.com/index24....(the map has nice zoom-in
> > > properties)
> >
> > > Best regards,
> >
> > And for most timezones, the utc offset depends also on the full time,
> since
> > it is different during the period, if any, for which daylight saving
> time is
> > observed for the particular timezone.
> >
> > The TZinfo gem can be used to handle this, once you dig in and
> understand
> > it.
> >
> > --
> > Rick DeNatale
> >
> > My blog on Rubyhttp://talklikeaduck.denh...
>
> Actually, this is for a Rails project. Will the Rails 2.1 help in this
> case?

You'll have to ask that on the Rails mailing list or test it out yourself.

Best regards,

Axel
--
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzz...

Earl Evleth

3/6/2011 12:38:00 PM

0

On 6/03/11 12:09, in article 4d736b69$0$7062$426a74cc@news.free.fr, "Paul
Aubrin" <chu8i443@free.fr> wrote:

> Something makes you suppose that the Russian Vostok station in Antarctica
> is global ?
>


CO2 concentrations are globally the same.

And there are other core sampling sites.

The Antarctics are the deepest and oldest.

http://en.wikipedia.org/wi...

It is all on the web, do you know how to use
the web? You know we will not dance to
your tune of asking questions expecting others
to answer. I have limited myself to a minimum
answer because of that.