Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread Patrick Nagel
Hi,

it's me again... I thought some more about

On 2009-03-05 03:09, Markus Krötzsch wrote:
 I suggest a slightly different control interface, though. The output is 
 only a problem for #ask queries, right?My suggestion is to use the existing 
 printout modifier mechanism that works for #ask printouts, so that one can 
 choose for each single printout which format to use. Example:
 
 {{#ask: ...
 | ?start date
 | ?end date#ISO
 }}

I think it would be best to also have a possibility to set the SMW-wide default 
to ISO8601, like in my proposal. Adding a possible printout modifier value 
localized (which would override the SMW-wide default setting) would then give 
all possibilities.

My reason behind this: I think users who are accustomed to the ISO8601 date 
format will find it peculiar to see the localised dates, which are still the 
unchangeable default in your implementation, and they show up in the Browse 
Properties output, for example.

Patrick.

-- 
Key ID: 0x86E346D4http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread CNIT

 Hi,

 it's me again... I thought some more about

 On 2009-03-05 03:09, Markus Krötzsch wrote:
   
 I suggest a slightly different control interface, though. The output is 
 only a problem for #ask queries, right?My suggestion is to use the existing 
 printout modifier mechanism that works for #ask printouts, so that one can 
 choose for each single printout which format to use. Example:

 {{#ask: ...
 | ?start date
 | ?end date#ISO
 }}
 

 I think it would be best to also have a possibility to set the SMW-wide 
 default 
 to ISO8601, like in my proposal. Adding a possible printout modifier value 
 localized (which would override the SMW-wide default setting) would then 
 give 
 all possibilities.

 My reason behind this: I think users who are accustomed to the ISO8601 date 
 format will find it peculiar to see the localised dates, which are still the 
 unchangeable default in your implementation, and they show up in the Browse 
 Properties output, for example.

 Patrick.

   
Only optionally. My users need localized dates.
I wonder whether the input of ISO8601 is accepted
(because the ISO8601 output may be given as input to another #ask 
template)..
ISO should be interesting for templating (both input and output).
Dmitriy

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread Patrick Nagel
Hi Dmitriy,

On 2009-03-05 16:51, CNIT wrote:
 I think it would be best to also have a possibility to set the 
 SMW-wide default to ISO8601, like in my proposal. Adding a possible 
 printout modifier value localized (which would override the SMW-wide 
 default setting) would then give all possibilities.
[...]
 Only optionally. My users need localized dates.

Yes, it should be optional (as in a global variable that can be set in 
LocalSettings.php), imo. The default should stay at 'localized', for backwards 
compatibility.

  I wonder whether the input of ISO8601 is accepted
  (because the ISO8601 output may be given as input to another #ask
  template)..
  ISO should be interesting for templating (both input and output).
  Dmitriy

There are a number of problems I discovered during a quick check:
Time zone designators are interpreted in the wrong way (try 
'2009-03-05T12:12:34+02:00', which should be output as '2009-03-05T10:12:34' on 
a Wiki that's running with UTC time and as '2009-03-05T18:12:34' on a Wiki 
that's running with China Standard Time timezone set). Or they cause the string 
to not be understood (try '2009-03-05T12:12:34+0200').

I'll try to come up with a patch that makes SMW understand more ISO8601 dates. 
I will only implement the (recommended) extended format (with hyphens / 
colons), not the basic format (without hyphens / colons). I don't know about 
week dates and ordinal dates yet, maybe in a second step.

Patrick.

-- 
Key ID: 0x86E346D4http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread CNIT
Patrick Nagel пишет:
 I'll try to come up with a patch that makes SMW understand more ISO8601 
 dates. 
 I will only implement the (recommended) extended format (with hyphens / 
 colons), not the basic format (without hyphens / colons). I don't know 
 about 
 week dates and ordinal dates yet, maybe in a second step.

   
Ordinal dates as input are very nice thing, they allow easily to build 
anniversaries
(memorable events that happened on the same day in previous years).
I was hoping to implement something like this myself, but not having enough
free time (and my coding probably is not reliable enough).
Dmitriy

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread Markus Krötzsch
My aggregated comments:
* ISO dates are not generally accepted as inputs. this is so because the 
default ISO order of date parts is not the same as the preferred default order 
in most languages (even in English). One could attempt a work-around based on 
the fact that all ISO years must be 4 digits long. I think there is even a bug 
for this already.
* I can imagine a global date format switch that may be set to ISO to make 
it a default for all dates. But I do not know which printout modifier to use 
for normal dates then (note that ISO is rather language neutral). I am 
thus inclined to opt against this extension.

-- Markus


On Donnerstag, 5. März 2009, CNIT wrote:
 Patrick Nagel пишет:
  I'll try to come up with a patch that makes SMW understand more ISO8601
  dates. I will only implement the (recommended) extended format (with
  hyphens / colons), not the basic format (without hyphens / colons). I
  don't know about week dates and ordinal dates yet, maybe in a second
  step.

 Ordinal dates as input are very nice thing, they allow easily to build
 anniversaries
 (memorable events that happened on the same day in previous years).
 I was hoping to implement something like this myself, but not having enough
 free time (and my coding probably is not reliable enough).
 Dmitriy

 ---
--- Open Source Business Conference (OSBC), March 24-25, 2009, San
 Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing
 the Enterprise -Strategies to boost innovation and cut costs with open
 source participation -Receive a $600 discount off the registration fee with
 the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
 ___
 Semediawiki-devel mailing list
 Semediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/semediawiki-devel



-- 
Markus Krötzsch
Semantic MediaWikihttp://semantic-mediawiki.org
http://korrekt.orgmar...@semantic-mediawiki.org



signature.asc
Description: This is a digitally signed message part.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-05 Thread Markus Krötzsch
On Donnerstag, 5. März 2009, Patrick Nagel wrote:
 Hi Markus,

 On 2009-03-05 03:09, Markus Krötzsch wrote:
  Could something like this be included in SMW?
 
  Yes. I suggest a slightly different control interface, though. The output
  is only a problem for #ask queries, right? My suggestion is to use the
  existing printout modifier mechanism that works for #ask printouts, so
  that one can choose for each single printout which format to use.
  Example:
 
  {{#ask: ...
 
  | ?start date
  | ?end date#ISO
 
  }}

 That's probably better for most. I have to go through all #ask queries
 then, and append '#ISO' everywhere, but that's ok :)

  This will show a three column table with start date in localized format
  and end date in ISO 8601 format. The ISO date is always completed
  (assuming January and 01 as defaults for month and day as in sorting).
  The time component may be omitted. If given, the time is separated by T
  as defined in the spec. Years are padded up to four digits, so you get
  things like 0010-05-06. Negative years, as suggested by ISO, represent
  BC dates, with 0 corresponding to 1 BC, -1 corresponding to 2 BC, and so
  on.

 Good catch, without the 'T' as separator between date and time it's not
 really ISO8601. Or at least something like -MM-DD hh:mm:ss (like in
 my patch) - according to [1] - is considered two separate, but acceptable,
 representations - one for date and the other for time. It is then left to
 the reader to interpret the two separate representations as meaning a
 single time point based on the context.

  All implemented in SVN.

 That was fast, thanks! :)

 There is one thing I'm not 100% sure about though: Your implementation
 always prints out a complete date, like '2009-03-05' by printing out a
 default of '01' for the MM and DD parts when they are undefined.

 The Wikipedia article describing ISO8601, section General principles [2]
 says: For reduced accuracy, any number of values may be dropped from any
 of the date and time representations, but in the order from the least to
 the most significant.

 So it would be possible to just omit the '-DD' or '-MM-DD' part when they
 are undefined. I would prefer this over SMW implying that the date is on
 January the 1st even though the precise point in time may actually be
 unknown. What do you think?

I also read that article :-) I decided against using partial dates because I 
assumed that it would complicate the life of people who use parser functions 
to post-process the dates (I think this is the main application of using ISO 
right now). Also, the old behaviour was to complete the date, so it recovers 
the kind of downwards compatibility that was asked for.

One could introduce more strings than ISO to have more fine-grained 
formatting options. But this gets us into the hell of date formatting (there 
are far too many options there) and of localization (man common formatting 
directives for dates are heavily biased towards English).

Markus


 Patrick.

 [1]:
 http://en.wikipedia.org/wiki/ISO8601#Combined_date_and_time_representations
 [2]: http://en.wikipedia.org/wiki/ISO8601#General_principles


-- 
Markus Krötzsch
Semantic MediaWikihttp://semantic-mediawiki.org
http://korrekt.orgmar...@semantic-mediawiki.org



signature.asc
Description: This is a digitally signed message part.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


[SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-04 Thread Patrick Nagel

Hi,

since I need our SMW to output ISO8601 date output (see [1]) I wrote a quick 
patch to SMW_DV_Time.php that honours the (newly introduced) 
$smwgISO8601DateOutput variable.


Could something like this be included in SMW?

Patrick.

[1]: 
http://sourceforge.net/mailarchive/forum.php?thread_name=49A223B5.1090608%40patrick-nagel.netforum_name=semediawiki-user


--
Key ID: 0x86E346D4http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4
--- SMW_DV_Time.php.original	2009-03-04 18:13:46.0 +0800
+++ SMW_DV_Time.php	2009-03-04 18:07:15.0 +0800
@@ -404,7 +404,7 @@
 	 * from the store.
 	 */
 	protected function makePrintoutValue() {
-		global $smwgContLang;
+		global $smwgContLang, $smwgISO8601DateOutput;
 		if ($this-m_printvalue === false) {
 			//MediaWiki date function is not applicable any more (no support for BC Dates)
 			if ($this-m_year  0) {
@@ -413,10 +413,18 @@
 $this-m_printvalue = number_format(-($this-m_year-1), 0, '.', '') . ' BC'; // note: there should be no digits after the comma anyway
 			}
 			if ($this-m_month) {
-$this-m_printvalue =  $smwgContLang-getMonthLabel($this-m_month) .   . $this-m_printvalue;
+if($smwgISO8601DateOutput === false) {
+	$this-m_printvalue =  $smwgContLang-getMonthLabel($this-m_month) .   . $this-m_printvalue;
+} else {
+	$this-m_printvalue =  $this-m_printvalue . '-' . str_pad($this-m_month, 2, 0, STR_PAD_LEFT);
+}
 			}
 			if ($this-m_day) {
-$this-m_printvalue =  $this-m_day .   . $this-m_printvalue;
+if($smwgISO8601DateOutput === false) {
+	$this-m_printvalue =  $this-m_day .   . $this-m_printvalue;
+} else {
+	$this-m_printvalue =  $this-m_printvalue . '-' . str_pad($this-m_day, 2, 0, STR_PAD_LEFT);
+}
 			}
 			if ($this-m_time) {
 $this-m_printvalue .=   . $this-m_time;
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-04 Thread Markus Krötzsch
On Mittwoch, 4. März 2009, Patrick Nagel wrote:
 Hi,

 since I need our SMW to output ISO8601 date output (see [1]) I wrote a
 quick patch to SMW_DV_Time.php that honours the (newly introduced)
 $smwgISO8601DateOutput variable.

 Could something like this be included in SMW?

Yes. I suggest a slightly different control interface, though. The output is 
only a problem for #ask queries, right? My suggestion is to use the existing 
printout modifier mechanism that works for #ask printouts, so that one can 
choose for each single printout which format to use. Example:

{{#ask: ...
| ?start date
| ?end date#ISO
}}

This will show a three column table with start date in localized format and 
end date in ISO 8601 format. The ISO date is always completed (assuming 
January and 01 as defaults for month and day as in sorting). The time 
component may be omitted. If given, the time is separated by T as defined in 
the spec. Years are padded up to four digits, so you get things like 
0010-05-06. Negative years, as suggested by ISO, represent BC dates, with 0 
corresponding to 1 BC, -1 corresponding to 2 BC, and so on.

All implemented in SVN.

Have fun,

Markus

P.S. I am very busy right now: it will take me some time to process other 
contributions. Please be patient, and possibly send a reminder if I should 
miss any contribution. Filing a bug/feature request + patch is of course the 
best thing to ensure things are not forgotten.


 Patrick.

 [1]:
 http://sourceforge.net/mailarchive/forum.php?thread_name=49A223B5.1090608%4
0patrick-nagel.netforum_name=semediawiki-user


-- 
Markus Krötzsch
Semantic MediaWikihttp://semantic-mediawiki.org
http://korrekt.orgmar...@semantic-mediawiki.org



signature.asc
Description: This is a digitally signed message part.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Patch to make SMW output ISO8601 dates

2009-03-04 Thread Patrick Nagel
Hi Markus,

On 2009-03-05 03:09, Markus Krötzsch wrote:
 Could something like this be included in SMW?
 
 Yes. I suggest a slightly different control interface, though. The output is 
 only a problem for #ask queries, right? My suggestion is to use the existing 
 printout modifier mechanism that works for #ask printouts, so that one can 
 choose for each single printout which format to use. Example:
 
 {{#ask: ...
 | ?start date
 | ?end date#ISO
 }}

That's probably better for most. I have to go through all #ask queries then, 
and append '#ISO' everywhere, but that's ok :)

 This will show a three column table with start date in localized format and 
 end date in ISO 8601 format. The ISO date is always completed (assuming 
 January and 01 as defaults for month and day as in sorting). The time 
 component may be omitted. If given, the time is separated by T as defined 
 in 
 the spec. Years are padded up to four digits, so you get things like 
 0010-05-06. Negative years, as suggested by ISO, represent BC dates, with 0 
 corresponding to 1 BC, -1 corresponding to 2 BC, and so on.

Good catch, without the 'T' as separator between date and time it's not really 
ISO8601. Or at least something like -MM-DD hh:mm:ss (like in my patch) - 
according to [1] - is considered two separate, but acceptable, representations 
- one for date and the other for time. It is then left to the reader to 
interpret the two separate representations as meaning a single time point based 
on the context.

 All implemented in SVN.

That was fast, thanks! :)

There is one thing I'm not 100% sure about though: Your implementation always 
prints out a complete date, like '2009-03-05' by printing out a default of '01' 
for the MM and DD parts when they are undefined.

The Wikipedia article describing ISO8601, section General principles [2] 
says: For reduced accuracy, any number of values may be dropped from any of 
the date and time representations, but in the order from the least to the most 
significant.

So it would be possible to just omit the '-DD' or '-MM-DD' part when they are 
undefined. I would prefer this over SMW implying that the date is on January 
the 1st even though the precise point in time may actually be unknown. What do 
you think?

Patrick.

[1]: http://en.wikipedia.org/wiki/ISO8601#Combined_date_and_time_representations
[2]: http://en.wikipedia.org/wiki/ISO8601#General_principles

-- 
Key ID: 0x86E346D4http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel