Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-9390: Blackberry: implement rest of String.formatXXX methods (other than format) #76

Merged

Conversation

alexandergalstyan
Copy link

Reviewers: HarutM, JP

Review the 99130f8

ChangeLog:

  • Added new TiDateObject class.
  • Added new message constants.
  • Implemented formatDate, formatTime, formatCurrency, formatDecimal methods

Test Cases:

  • Using sample tibbtest project create var with the value of Date
  • Use formatDate(date, [format]), formatTime(date, [format]) in app.js
  • Make sure string correctly formatted.
  • Try the same with previously changed language.
  • Create var with number value.
  • Use formatCurrency(number) in app.js
  • Make sure string correctly formatted.
  • Try the same with previously changed language.
  • Create var with number value.
  • Use formatDecimal(number, [locale], [pattern]) in app.js
  • Make sure string correctly formatted.
  • Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal

Test snippet from app.js:
//
// create root window
//
var win1 = Titanium.UI.createWindow({
backgroundColor:'#F00'
});

var date = new Date();
var format = String.formatDate(date, 'short');

//var date = new Date();
//var format = String.formatDate(date, 'medium');

//var date = new Date();
//var format = String.formatDate(date, 'long');

//var date = new Date();
//var format = String.formatTime(date, 'short');

//var date = new Date();
//var format = String.formatTime(date, 'medium');

//var date = new Date();
//var format = String.formatTime(date, 'long');

var label1 = Ti.UI.createLabel({
textAlign : 'center',
text:'Hello, world!',
color:'green',
top: 200
});

label1.text = format;

win1.add(label1);

// open window
win1.open();

unknown added 4 commits June 9, 2012 15:28
…rry' into formatReview

#Some more info....
Reviewers: DavidC, JP

ChangeLog:
- Implement decode/encode URIComponent

Test Cases:
- Using sample tibbtest project create var with the value of:
  'http://www.example.com/List%20of%20holidays.xml'
- Use decodeURIComponent to decode the uri.
- Make sure it decodes successfully.
- Using sample tibbtest project create var with the value of:
    'http://www.example.com/List of holidays.xml'
- Use encodeURIComponent to encode the uri.
- Make sure it encodes successfully.
…ther than format)

Reviewers: HarutM, JP

ChangeLog:
- Added new TiDateObject class.
- Added new message constants.
- Implemented formatDate, formatTime, formatCurrency, formatDecimal methods

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal
@jpl-mac
Copy link

jpl-mac commented Jun 12, 2012

Can you be more explicit on the test cases? If i were to try and run these tests on my own, i wouldn't know what to do or look for.

what's a "var with value of Date"?
what's the [format] in "Use formatDate(date, [format]), formatTime(date, [format])"
etc.

The value behind the Tests section in the patch description is so a QA or someone else with no knowledge of the patch can look at the tests and run them.
Then the tests could be as simple as build this app.js snippet for BB and compare with the same built for Android or Iphone..
Maybe it's time we start providing the app.js file we used for the development/testing of a patch. the app.js snippet could be added here as a comment.

DATE_FORMAT_LONG,
DATE_FORMAT_MEDIUM,
DATE_FORMAT_SHORT
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be used anywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@jpl-mac
Copy link

jpl-mac commented Jun 12, 2012

apidoc needs to be updated


Local<Object> obj = Object::Cast(*value);
// Get year property
Local<Value> getYear_prop = (Object::Cast(*value)->Get(String::New("getFullYear")));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just use obj instead of casting *value everytime?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@jpl-mac
Copy link

jpl-mac commented Jun 12, 2012

Reviewed

@@ -0,0 +1,9 @@

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this cpp file?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the constants need to be defined in a cpp.

it's macro dark magic :)

…ther than format) ver2

ChangeLog:
- Address comments.
- Update String.yml apidoc.
- Change the QDateTime to QTime for formatTime method.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal
NOTE: test snippet available at discussion page.
@alexandergalstyan
Copy link
Author

Updated. Added test cases snippets

@Harutyun
Copy link

Reviewed

unknown added 3 commits June 18, 2012 13:06
Conflicts:
	blackberry/tibb/TiRootObject.cpp
…rry' into formatBranch

#Some more info....
…ther than format) ver3

Reviewers: HarutM, JP

Review the 99130f8

ChangeLog:
- Remove TiDateObject class.
- Address comments.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
@alexandergalstyan
Copy link
Author

Updated behalf on #82

@jpl-mac
Copy link

jpl-mac commented Jun 18, 2012

Now that you also have the patch for built-in JS keywords, it would be good to validate the use of StringObjects and then remove the TODOs

unknown added 2 commits June 21, 2012 18:14
…rry' into formatBranch

#Some more info....
…89' into formatBranch

Conflicts:
	blackberry/tibb/TiRootObject.cpp
	blackberry/tibb/TiStringObject.cpp
// Try to parse optional format argument
if (args.Length() > 1 && (args[1]->IsString() || args[1]->IsStringObject()))
{
const String::Utf8Value utf8(args[1]->ToString());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually some care is needed around using ToString().

So we want to convert non string litteral (IsString() == true) args using ToString() when a string is expected, but we don't want to call ToString on strings.

This is the behaviour that we see from the chrome js console. So far i've had ToString() return a null pointer on string literals so that stopped me from using ToString on all args. If it works for you though you could do that.

This comment also applies to the other use further down

if (args.Length() > 1)
{
Local<Value> format = args[1];
if (!(format->IsString() || format->IsStringObject()))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition only needs to check for IsString. The ToString() methods should be applied to StringObjects also. This is how JS behaves in Chrome.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@jpl-mac
Copy link

jpl-mac commented Jun 22, 2012

Rereviewed

unknown added 2 commits June 25, 2012 13:44
…rry' into formatBranch

Conflicts:
	blackberry/tibbtest/app.js
…ther than format) ver3

Reviewers: HarutM, JP

Review the 99130f8

ChangeLog:
- Remove TiDateObject class.
- Address comments.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
@alexandergalstyan
Copy link
Author

Updated.

static QString formatString(QString s, Local<Value> arg);
static QString formatPointer(QString s, Local<Value> arg);

// Helper function
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prototypes above is for helper functions, this one can be bunched with the others at merge time

@jpl-mac
Copy link

jpl-mac commented Jun 26, 2012

Approved with trivial comment, can be done at merge time

I don't think Harut has approved yet. Also this PR needs to wait for #84 to be merged first.

@Harutyun
Copy link

Approved

…rry' into formatBranch

Conflicts:
	blackberry/tibb/NativeStringInterface.cpp
	blackberry/tibb/TiMessageStrings.h
	blackberry/tibb/TiRootObject.cpp
…ther than format) ver4

Reviewers: HarutM, JP

ChangeLog:
- Address comments.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal

Test snippet from app.js:
 //
 // create root window
 //
 var win1 = Titanium.UI.createWindow({

 backgroundColor:'#F00'
 });

var date = new Date();
 var format = String.formatDate(date, 'short');

//var date = new Date();
 //var format = String.formatDate(date, 'medium');

//var date = new Date();
 //var format = String.formatDate(date, 'long');

//var date = new Date();
 //var format = String.formatTime(date, 'short');

//var date = new Date();
 //var format = String.formatTime(date, 'medium');

//var date = new Date();
 //var format = String.formatTime(date, 'long');

var label1 = Ti.UI.createLabel({
 textAlign : 'center',
 text:'Hello, world!',
 color:'green',
 top: 200
 });

label1.text = format;

win1.add(label1);

// open window
 win1.open();
@@ -22,6 +22,7 @@
{

N_MESSAGESTRINGS_CONST_DEF(char*, An_error_occurred_converting_to_int, "An error occurred converting to int");
N_MESSAGESTRINGS_CONST_DEF(char*, Expected_argument_of_type_date, "Expected argument of type date");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial: Date type in js is with a capital D so the message should reflect that, can be done at merge time

…ther than format)

Reviewers: HarutM, JP

ChangeLog:
- Move the date conversion logics into the NativeControlObject.
- Address comments.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal

Test snippet from app.js:
 //
 // create root window
 //
 var win1 = Titanium.UI.createWindow({

 backgroundColor:'#F00'
 });

var date = new Date();
 var format = String.formatDate(date, 'short');

//var date = new Date();
 //var format = String.formatDate(date, 'medium');

//var date = new Date();
 //var format = String.formatDate(date, 'long');

//var date = new Date();
 //var format = String.formatTime(date, 'short');

//var date = new Date();
 //var format = String.formatTime(date, 'medium');

//var date = new Date();
 //var format = String.formatTime(date, 'long');

var label1 = Ti.UI.createLabel({
 textAlign : 'center',
 text:'Hello, world!',
 color:'green',
 top: 200
 });

label1.text = format;

win1.add(label1);

// open window
 win1.open();
@alexandergalstyan
Copy link
Author

Updated.

@@ -7,7 +7,7 @@

#include "NativeDateTimePickerObject.h"

#include "ConversionHelper.h"
#include "NativeControlObject.h"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be necessary as it's already a parent class of NDTP

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

…rry' into formatBranch

Conflicts:
	blackberry/tibb/NativeControlObject.cpp
…ther than format) ver6

Reviewers: HarutM, JP

ChangeLog:
- Address comments.
- Remove ConversionHelper class.

Test Cases:
- Using sample tibbtest project create var with the value of Date
- Use formatDate(date, [format]), formatTime(date, [format]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatCurrency(number) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.
- Create var with number value.
- Use formatDecimal(number, [locale], [pattern]) in app.js
- Make sure string correctly formatted.
- Try the same with previously changed language.

NOTE: locale & pattern not yet implemented for formatDecimal

Test snippet from app.js:
 //
 // create root window
 //
 var win1 = Titanium.UI.createWindow({

 backgroundColor:'#F00'
 });

var date = new Date();
 var format = String.formatDate(date, 'short');

//var date = new Date();
 //var format = String.formatDate(date, 'medium');

//var date = new Date();
 //var format = String.formatDate(date, 'long');

//var date = new Date();
 //var format = String.formatTime(date, 'short');

//var date = new Date();
 //var format = String.formatTime(date, 'medium');

//var date = new Date();
 //var format = String.formatTime(date, 'long');

var label1 = Ti.UI.createLabel({
 textAlign : 'center',
 text:'Hello, world!',
 color:'green',
 top: 200
 });

label1.text = format;

win1.add(label1);

// open window
 win1.open();
@alexandergalstyan
Copy link
Author

Updated

@jpl-mac
Copy link

jpl-mac commented Jul 11, 2012

Approved with comment

@Harutyun
Copy link

Approved

alexandergalstyan added a commit that referenced this pull request Jul 11, 2012
TIMOB-9390: Blackberry: implement rest of String.formatXXX methods (other than format)
@alexandergalstyan alexandergalstyan merged commit fddf0b1 into Macadamian:blackberry Jul 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants