[OpenAjaxIDE] date formatting

Jon Ferraiolo jferrai at us.ibm.com
Tue Aug 25 08:25:04 PDT 2009


'outputFormat' is fine with me.

In an attempt to move the discussion forward, here is a proposal on the
details.

We should define this attribute only for datatype="Date" at this time. For
all other values for 'datatype', the attribute is ignored.

The processing model is that we assume the developer tool has a timezone
aware date/time value in hand (for browser-based tools, this would be a
JavaScript Date object). The 'outputFormat' attribute specifies the string
representation of the date/time value when placed into the deployed HTML
page, where the following substitutions happen:

every occurrence of YYYY gets replaced with the string representation of
the year
every occurrence of MM gets replaced with the string representation of the
month (1-12)
every occurrence of DD gets replaced with the string representation of the
day (0-31)
every occurrence of hh gets replaced with the string representation of the
hour (0-23)
every occurrence of mm gets replaced with the string representation of the
minute (0-59)
every occurrence of ss gets replaced with the string representation of the
second (0-59)
every occurrence of ms gets replaced with the string representation of the
millisecond (0-999)
all other characters from the outputFormat string are copied into the
result string

To illustrate,
* If outputFormat="YYYYMMDD" and the date value is March 15, 2009, then the
generated string would be "20091503"
* If outputFormat="YYYY-MM-DD" and the date value is March 15, 2009, then
the generated string would be "2009-15-03"
* If outputFormat="YYYY/MM/DD" and the date value is March 15, 2009, then
the generated string would be "2009/15/03"
* If outputFormat="hello", then the generated string would be "hello" (no
substitution matches)

Developer tools must put leading zeroes on values. Therefore, March must be
'03' and not '3'.

However, we need to address timezones to address the question of whether
the generated value supposed to be in the UTC timezone or the local
timezone. I would propose we assume the local timezone. If someone needs
UTC or other timezones, then they will have to resort to JavaScript.

Jon





                                                                                                        
  From:       Kin Blas <jblas at adobe.com>                                                                
                                                                                                        
  To:         "ide at openajax.org" <ide at openajax.org>                                                     
                                                                                                        
  Date:       08/24/2009 05:24 PM                                                                       
                                                                                                        
  Subject:    Re: [OpenAjaxIDE] date formatting                                                         
                                                                                                        
  Sent by:    ide-bounces at openajax.org                                                                  
                                                                                                        





Regarding #2, I don’t like the idea of introducing an attribute for every
datatype/format combo. We should just have one attribute, perhaps
“outputFormat”, named generically on purpose, and just document what
datatype/format are allowed to use it, and what the expected values for
that attribute are for the various datatype/format combos that support it.
In hindsight, we really should have named the @format something different
since its purpose is to  hint the type of control to use to gather its
value … it’s more of a UI display hint instead of a format.

We don’t have to support an output format for *every* dataType right off
the bat, but we do definitely need something for Dates since there are a
multitude of representations for it.,

--== Kin ==--

From: ide-bounces at openajax.org [mailto:ide-bounces at openajax.org] On Behalf
Of Jon Ferraiolo
Sent: Thursday, August 20, 2009 4:36 PM
To: Scott Richards
Cc: ide at openajax.org
Subject: Re: [OpenAjaxIDE] date formatting



Hi Scott,
Good email! Thanks!

I'll comment on two parts of your email:

(1) Scott says: selected: new Date(2009,0,31)...Are others writing out the
Javascript Date constructor in this scenario?
Response: It probably depends whether the tool runs in the browser or not.
Dreamweaver is its own executable, and generates the HTML file via fprintf
(or equivalent), so the above logic makes sense. However, if your have a
runt-ime tool such as a mashup builder, then you very well might call the
YUI constructor functions directly from the tool, and therefore you might
have a Date object in hand.

(2) Scott says: I like the name ‘dateFormat’ Jon proposed, but would this
mean we would have a different ‘timeFormat’ and ‘timestampFormat’?
Response: Yes, I did in fact propose 'dateFormat', and that would indeed
imply that if we needed formatting for other datatypes (now or in the
future), then we would need multiple new attributes, such as 'timeFormat',
'timestampFormat', 'numberFormat', and maybe 'currencyFormat' or
'addressFormat' down the road. We could also a single attribute that
supports different formatting substitution syntaxes based on the values of
either 'datatype' or 'format'.

This all points out the slippery slope that we are on. If we support
declarative formatting for dates, then why not for other datatypes?

Jon



Inactive hide details for Scott Richards ---08/20/2009 04:09:47 PM---Jon
you make a good point about the need to separate out tScott Richards
---08/20/2009 04:09:47 PM---Jon you make a good point about the need to
separate out the attributes format = is the clue for wha


                                                                           
                                                                           
 From:         Scott Richards <scrichar at adobe.com>                         
                                                                           
                                                                           
 To:           Jon Ferraiolo/Menlo Park/IBM at IBMUS, "ide at openajax.org"      
               <ide at openajax.org>                                          
                                                                           
                                                                           
 Date:         08/20/2009 04:09 PM                                         
                                                                           
                                                                           
 Subject:      RE: [OpenAjaxIDE] date formatting                           
                                                                           






Jon you make a good point about the need to separate out the attributes
format = is the clue for what UI control the IDE should display for the end
user to configure that property and the

I can understand if everyone does not want to take the extra effort to
support flexibility in supporting different date formats, or wants to defer
on this till the 2.0 version of the spec.  But we would like to provide
this capability now even if it does not make it into the 1.0 spec. So we
would like to come up with a proposal that will hopefully be accepted if
not now in the next spec..  Minimally the spec needs to state what the
format will be when the user specifies format=”date”, format=”time”, and
format=”timestamp”. Currently it is unclear now what this property will
write out when it does the substitution and what the expected format of the
defaultValue should be.

At Adobe currently we are always outputting a Javascript Date Constructor.
And we are expecting the defaultValue to be formatted as MM/DD/YYYY. We are
not differentiating between format=”date” and format=”string”

So if you specify this in the oam.xml file

<javascript>
                        var cal1 = new YAHOO.widget.Calendar
                        ("cal1","cal1Container",{ selected:
                        @@selectDate@@ });
</javascript>

<property name=”selectedDate” datatype=”date” defaultValue=”1/31/2009” />);


We display a date picker control that defaults to January 31 2009, and we
would write out the following to the code if the user did not select a
different date then the default one.
                        var cal1 = new YAHOO.widget.Calendar
                        ("cal1","cal1Container",{ selected: new Date
                        (2009,0,31)});

Are others writing out the Javascript Date constructor in this scenario?
How are people handling defaultValue for format=”date”?  Are others
behaving differently if the format=”string” versus format=”date”?

We should be consistent between the format of the defaultValue and the
value we output.  And we want to enable at least some limited options in
the format other than the Javascript Date constructor.  It seems odd to me
to specify defaultValues in the oam.xml file as Javascript Date
constructors (with January = 0).

We do not have a time control so we have not dealt with that case yet.

I like the name ‘dateFormat’ Jon proposed, but would this mean we would
have a different ‘timeFormat’ and ‘timestampFormat’?

To keep this simple and but provide a little bit of flexibility and to go
with an accepted standard I think the formats specified in ISO8601 below
would be better than all of the formats that php supports.

YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)

Also, Steve it would be great if you could share your code with the group

-Scott

From: ide-bounces at openajax.org [mailto:ide-bounces at openajax.org.] On Behalf
Of Jon Ferraiolo
Sent: Thursday, August 20, 2009 7:56 AM
To: ide at openajax.org
Subject: Re: [OpenAjaxIDE] date formatting


If we add another attribute, its name should reflect that the attribute
only applies to formatting dates versus other datatypes. Therefore, instead
of 'formatString', the attribute should be named something like
'formatDate', 'dateFormat' or 'dateResultFormat'. (The latter one is long,
but re-inforces that we are formatting on the property editor result rather
than the input value that is given the property editor.)

But like Adam I would like to see side-by-side comparisons of how the OAM
file would look if we added a new attribute versus pushing this feature
into something that has to be done via JavaScript. I'll take a crack at it.


With a 'dateResultFormat' attribute:

<property name='mindate' datatype='String' format='date'
dateResultFormat='MM/DD/YYYY'/>
<javascript location="afterContent">
var calwidget = new YAHOO.whatever.calendar({...mindate:@@mindate@@...});
</javascript>

Without a 'dateResultFormat' attribute:

<property name='mindate' datatype='Date' format='date'/>
<javascript location="afterContent">
var mdate = @@mindate@@;
var mdate_string = mdate.getMonth()+"/"+mdate.getDay
()+"/"+mdate.getFullYear();
var calwidget = new YAHOO.whatever.calendar({...mindate:mdate_string...});
</javascript>

Jon



Inactive hide details for Lori Hylan-Cho ---08/19/2009 10:41:14 PM---I
agree with Kin that we shouldn't make widget developers Lori Hylan-Cho
---08/19/2009 10:41:14 PM---I agree with Kin that we shouldn't make widget
developers (or oam.xml file writers, who may not be


                                                                           
                                                                           
 From:   Lori Hylan-Cho <avocadoh at gmail.com>                               
                                                                           
                                                                           
 To:     Jon Ferraiolo/Menlo Park/IBM at IBMUS                                
                                                                           
                                                                           
 Cc:     Kin Blas <jblas at adobe.com>, "ide at openajax.org" <ide at openajax.org> 
                                                                           
                                                                           
 Date:   08/19/2009 10:41 PM                                               
                                                                           
                                                                           
 Subject Re: [OpenAjaxIDE] date formatting                                 
 :                                                                         
                                                                           







I agree with Kin that we shouldn't make widget developers (or oam.xml file
writers, who may not be the same people) write extra JS when we can include
a declarative format in the spec.

I agree with Jon and Scott that a separate attribute for the format string
should be used for the reason Jon outlined.

As regards encouraging bad coding practices, I'd rather recognize reality
and give dev tools a chance to support it than try to get everyone to
conform to an ideal.

Lori

[brevity brought to you by iPhone.]

On Aug 19, 2009, at 9:55 PM, Jon Ferraiolo <jferrai at us.ibm.com> wrote:
                        After thinking about things, I don't like either of
                        the following:

                        format="d/m/Y"

                        or

                        format="date(d/m/Y)"

                        The 'format' attribute tells the tool what type of
                        special editor to display within the property
                        editor in order for the user to enter a value. For
                        example, a tool might provide a calendar widget to
                        edit a property that has format="date", a clock
                        dial widget to edit a property that has
                        format="time", and a color picker widget to edit a
                        property that has format="color". I don't think we
                        want to try to co-mingle the formatting
                        instructions into the same attribute that provides
                        a hint about which editor widget to use within the
                        property editor UI.

                        If we are going to offer date formatting, I think
                        an additional attribute such as what Scott has
                        proposed is the way to go.

                        Regarding whether we should include this feature or
                        not, I won't object if the majority think this is a
                        necessary feature for version 1.0, but at the
                        moment I'm not sold that this is an appropriate
                        feature for the spec. Two things worry me:

                        (1) So far, I haven't seen any JavaScript-free OAM
                        files for OAM files that wrap widgets from Ajax
                        toolkits. If OAM authors need to resort to
                        JavaScript anyway, then for the YUI calendar widget
                        (and similar calendar widgets), the widget
                        developer working on the calendar widget can figure
                        out how to format the date values (perhaps by
                        including Steve's 40 lines of JavaScript within
                        that particular widget)

                        (2) I'm not sure that it is compelling easier for a
                        widget developer to discover and learn how to use
                        the 'formatString' attribute versus writing a
                        little JavaScript to create the appropriate string
                        before calling the constructor.

                        But nevertheless, if the majority want this
                        feature, I'm OK with adding it as Scott proposes
                        below.

                        Jon


                        <graycol.gif>Kin Blas ---08/19/2009 03:21:31
                        PM---For the datatype="Date" there are 2 supported
                        format values, "date" and "time": <property
                        name="myDa


                                                                           
 <ecblank.gif>         <ecblank.gif>                                       
 From:                 Kin Blas <jblas at adobe.com>                          
                                                                           
 <ecblank.gif>         <ecblank.gif>                                       
 To:                   "ナide at openajax.org" <ide at openajax.org>              
                                                                           
 <ecblank.gif>         <ecblank.gif>                                       
 Date:                 08/19/2009 03:21 PM                                 
                                                                           
 <ecblank.gif>         <ecblank.gif>                                       
 Subject:              Re: [OpenAjaxIDE] date formatting                   
                                                                           
 <ecblank.gif>         <ecblank.gif>                                       
 Sent by:              ide-bounces at openajax.org                            
                                                                           







                        For the datatype=”Date” there are 2 supported
                        format values, “date” and “time”:

                        <property name=”myDate” datatype=”Date”
                        format=”date” />
                        <property name=”myTime” datatype=”Date”
                        format=”time” />

                        Rather than introducing another attribute, as
                        proposed in Scott’s example. Why not just leverage
                        the existing @format attribute in conjunction with
                        the variables used by PHP:

                        http://us.php.net/manual/en/function.date.php.

                        The current proposed values for the Date @format
                        aren’t that useful in my opinion. So I envision
                        something like:

                        <property name=”myDate” datatype=”Date”
                        format=”d/m/Y” />
                        <property name=”myTime” datatype=”Date”
                        format=”g:i:s” />

                        Regarding Jon’s comment about being able to work
                        around this problem with additional code added to
                        the <javascript> or <content> sections … I really
                        feel that if we want this OAM format to be adopted
                        by the various frameworks and the industry, that we
                        need to make it drop-dead simple for them to
                        support their formats/patterns so they don’t have
                        to resort to writing extra-glue code to make up for
                        our in-flexibility.

                        --== Kin ==--

                        From: ide-bounces at openajax.org [
                        mailto:ide-bounces at openajax.org.] On Behalf Of
                        Scott Richards
                        Sent: Wednesday, August 19, 2009 3:00 PM
                        To: Steve Repetti; 'Jon Ferraiolo';
                        ide at openajax.org
                        Subject: Re: [OpenAjaxIDE] date formatting

                        I think a lightweight solution that supports a very
                        small set of legacy formats would be all we need.
                        Sounds like Steve’s 40+ lines of DateFormat code
                        could handle this.

                        I like a simple approach of adding an additional
                        formatString=”” attribute or maybe call it
                        formatPattern that enables you to format in the
                        value that is replaced using the @@variableName@@
                        notation in either the <javascript> or <content>
                        sections. Here is an example.

                        <property datatype=”date” format=”date”
                        formatString=”YYYY-MM-DD” />


                        where:
                        YYYY = four-digit year
                        MM = two-digit month (01=January, etc.)
                        DD = two-digit day of month (01 through 31)
                        hh = two digits of hour (00 through 23) (am/pm NOT
                        allowed)
                        mm = two digits of minute (00 through 59)
                        ss = two digits of second (00 through 59)



                        The formats from YUI Calendar takes Javascript Date
                        Object or a string formatted as “mm/yyyy” and
                        “mm/dd/yyyy”. The selected property can only be
                        specified with a string not a Javascript date
                        object and it does not support ISO 8601 format. See
                        this link

                        http://developer.yahoo.com/yui/calendar/#config

                        Here is an example of how we could support YUI
                        Calendar date strings using formatString.


                        var cal1 = new YAHOO.widget.Calendar("cal1",
                        "cal1Container",
                        { pagedate:"5/2007",
                        selected:"5/5/2007-5/27/2007" });

                        This would look like the following in the oam.xml
                        file:
                                                                        <javascript>
                        var cal1 = new YAHOO.widget.Calendar("cal1",
                        "cal1Container",
                        { pagedate:"@@pageDate@@",
                        selected:"@@selectDateStart@@-@@selectDateEnd@@" });

                                                                        </javascript>


                                                                        <property
 name=”pageDate” datatype=”date” format=”date” formatString=”MM/YYYY” />
                                                                        <property
 name=”

                                                                        selectDateStart”
 datatype=”date” format=”date” formatString=”MM/DD/YYYY” />
                                                                        <property
 name=””

                                                                        selectDateEnd”
 datatype=”date” format=”date” formatString=”MM/DD/YYYY” />


                        Not sure if we should support dropping out leading
                        0’s, do we need to support this? We could do with
                        just M or D. But the YUI calendar works specifying
                        dates with or without leading 0’s. So this may be
                        unnecessary.



                        Here is the link for jQuery Date formats. They
                        support multiple formats including iso 8601. So
                        with could support it as follows:
                        _______________________________________________
                        IDE mailing list
                        IDE at openajax.org
                        http://openajax.org/mailman/listinfo/ide
                        _______________________________________________
                        IDE mailing list
                        IDE at openajax.org
                        http://openajax.org/mailman/listinfo/ide

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20090825/bf1715ef/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://openajax.org/pipermail/ide/attachments/20090825/bf1715ef/attachment-0002.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://openajax.org/pipermail/ide/attachments/20090825/bf1715ef/attachment-0003.gif 


More information about the IDE mailing list