PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > DateTime in UTC
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
DateTime in UTC

Réponse
 
LinkBack Outils de la discussion
Vieux 22/08/2008, 10h41   #1
bcparanj@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut DateTime in UTC

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.
  Réponse avec citation
Vieux 22/08/2008, 10h55   #2
Axel Etzold
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC

> 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/messenger03

  Réponse avec citation
Vieux 22/08/2008, 11h11   #3
Peña, Botp
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC

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

  Réponse avec citation
Vieux 22/08/2008, 20h30   #4
bcparanj@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC

On Aug 22, 1:55am, 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/messenger03


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

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.
  Réponse avec citation
Vieux 22/08/2008, 20h34   #5
bcparanj@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC


> I created the following list of the expected behavior fromhttp://www.google.com/googlecalendar/event_publisher_guide.html
>
> 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.
  Réponse avec citation
Vieux 22/08/2008, 20h52   #6
Axel Etzold
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC


-------- 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_guide.html
> >
> > 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.rubyforge.org/
http://www.worldtimezone.com/index24.html (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/smartsurfer

  Réponse avec citation
Vieux 23/08/2008, 00h04   #7
Rick DeNatale
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC

[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_guide.html
> > >
> > > 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.rubyforge.org/
> http://www.worldtimezone.com/index24.html (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.denhaven2.com/

  Réponse avec citation
Vieux 23/08/2008, 00h57   #8
bcparanj@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DateTime in UTC

On Aug 22, 3:04pm, 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_guide.html

>
> > > > 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.rubyforge.org/
> >http://www.worldtimezone.com/index24.html(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 timeis
> 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.denhaven2.com/


Actually, this is for a Rails project. Will the Rails 2.1 in this
case?
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h36.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,54526 seconds with 16 queries