Dates: ISO 8601

2007-03-07 Thread David Bovill

I need a handler to convert a Rev date into ISO 8601?


From my library I have a rough and ready one to go the other way round:


on date_Convert8601 @revisionDate
   -- was date_ConvertT
   replace T with return in revisionDate
   put line 1 of revisionDate into someDate

   put line 2 of revisionDate into someTime
   put last char of someTime into timeZoneThing
   delete last char of someTime

   replace - with comma in someDate

   set the itemdelimiter to .
   put item 1 of someTime into colonTime
   put item 2 of someTime into colonSeconds
   replace : with comma in colonTime

   set the itemdelimiter to comma
   put someDate into someDateItems
   put colonTime into item 4 of someDateItems

   put 0 into item 7 of someDateItems

   convert someDateItems to internet date
   delete word -1 of someDateItems
   convert someDateItems to internet date
   put someDateItems into revisionDate
end date_Convert8601

But seem to have lost the other side of the equation )
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Dates: ISO 8601

2007-03-07 Thread Klaus Major

Hi David,


I need a handler to convert a Rev date into ISO 8601?

From my library I have a rough and ready one to go the other way  
round:


on date_Convert8601 @revisionDate
   -- was date_ConvertT
   replace T with return in revisionDate
   put line 1 of revisionDate into someDate

   put line 2 of revisionDate into someTime
   put last char of someTime into timeZoneThing
   delete last char of someTime

   replace - with comma in someDate

   set the itemdelimiter to .
   put item 1 of someTime into colonTime
   put item 2 of someTime into colonSeconds
   replace : with comma in colonTime

   set the itemdelimiter to comma
   put someDate into someDateItems
   put colonTime into item 4 of someDateItems

   put 0 into item 7 of someDateItems

   convert someDateItems to internet date
   delete word -1 of someDateItems
   convert someDateItems to internet date
   put someDateItems into revisionDate
end date_Convert8601

But seem to have lost the other side of the equation )


a little example on how a date should look according to ISO 8601  
MIGHT help

us to help you faster  ;-)


Regards

Klaus Major
[EMAIL PROTECTED]
http://www.major-k.de

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Dates: ISO 8601

2007-03-07 Thread David Bovill

Hi Klaus - I was just thinking someone out there must have a ready made
handler as it is real common format on the internet. I've given a go below -
I include some info for reference:

A common use could be []-[MM]-[DD]T[hh]:[mm]:[ss]±[hh]:[mm].

1981-04-05T14:30:30-05:00, for example.



Two good references:

  1. http://www.w3.org/TR/NOTE-datetime
  2. http://en.wikipedia.org/wiki/ISO_8601#Combined_representations

So it's basically dateitems with dashes a T in the middle and a Z or bit
from the internet time (UTC) at the end - not too clear on the timezone
stuff.


UTC

If the time is in UTChttp://en.wikipedia.org/wiki/Coordinated_Universal_Time,
it is very easy to show this. Simply add a 'Z' directly after the time,
without a space. 09:30 UTC is therefore represented as 09:30Z or
0930Z. 14:45:15 UTC would be 14:45:15Z or 144515Z.

[edithttp://en.wikipedia.org/w/index.php?title=ISO_8601action=editsection=12
] Other time zones

Other time zones are specified by their *offset* from UTC, in the format
±[hh]:[mm], ±[hh][mm] or ±[hh]. So if the time being described is one hour
ahead of UTC (such as the time in Berlinhttp://en.wikipedia.org/wiki/Berlinduring the winter) the offset 
would be +01:00, +0100 or simply +01.
This is appended to the time in the same way that 'Z' was above. Note that
the offset is the actual offset from UTC, and does not include any
information on daylight saving 
timehttp://en.wikipedia.org/wiki/Daylight_saving_time.
Times expressed in local time for a user in 
Chicagohttp://en.wikipedia.org/wiki/Chicagowould be -06:00 for the winter 
(Central
Standard Time http://en.wikipedia.org/wiki/Central_Standard_Time_Zone)
and -05:00 for the summer (Central Daylight 
Timehttp://en.wikipedia.org/wiki/Central_Daylight_Time_Zone).
The following times all refer to the same moment: 18:30Z, 22:30+04,
1130-0700 and 15:00-03:30.


So this seems to work:

function date_Construct8601 someDate
   -- ie 1981-04-05T14:30:30-05:00
   convert someDate to internet date
   put word -1 of somedate into utcOffset
   convert someDate to dateItems
   put item 1 to 3 of someDate into dateBit
   replace comma with - in dateBit
   put item 3 to 6 of somedate into timeBit
   replace comma with : in timeBit

   return dateBit  T  timeBit  utcOffset
end date_Construct8601
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution