Chrome Flash Player (Pepper) date timezoneOffset bug - apache-flex

I had a hard time finding anything on this critical problem so I decide to post this to help users running into the same issue.
The Chrome embedded Flash Player (Pepper) has a bug concerning date timezoneOffset that leads to some unpredictable behaviors when your application deals with dates.
As we provide a commercial Flex calendar component (KC-Calendar), this issue is critical for our clients and for their applications.
The issue details can be found here: http://code.google.com/p/chromium/issues/detail?id=154060
(please vote)
Waiting for a fix, if someone has a workaround, it could be really helpful.
Thanks in advance!

We've dealt with such issues before, and honestly--rather than playing around with trying to serialize Dates--IMO the best solution (unless you WANT auto timezone conversion) is to simply pass date data types as strings. We do this cleanly using Java and ActionScript getters/setters which (correctly) set the serialized "date" objects in our DTO by parsing the un-adjusted date strings.
Ex. when you set a Date object's value, in the setter you convert Date to String & set a String field for that date. In the getter you get the String value for that date and parse it, returning a new Date object. Do this on server and client side.
The only minor caveat, obviously, is that you need to ensure the Flex & server side String-to-Date/Date-To-String functions use the same date format. Just put a nice comment explaining this (so nobody screws with it) next to your serialization date parsers/formatters and you're fine.
I expect this issue will probably go away once an HTML5-based Flex compiler is released (it's really just a Flash feature which isn't the desired behavior in our cases).

Related

What's best practice in this situation?

I was just writing a small asp.net web page to display a collection of objects by binding to a repeater, when this came to mind.
Basically the class I've created, let's call it 'Test', has a price property that's an integer data type (ignore the limitations of using this type, I'm just using it as an example). However I want to format this property so it displays a currency and the correct decimal places etc.
Is it best practice to have a function within the class that returns the formatted string for the object, or would it be better to have a function in the back end of my web form that operations on the object and returns the formatted string?
I've heard before that a class should contain all it's relative functions but I've also heard that presentation should be kept in the 'presentation layer' in my N-tier app.
What would be the best approach in my situation? (and apologies if I haven't explained this clearly enough!)
Thanks!
In my opinion, both options are valid from an OO point of view.
Since the value is a price (that just happens to have the wrong data type), it makes sense to put the formatting into the data class. It's not something that's specific to the web interface, and, if you develop a different kind of user interface, you are very likely to require this formatting again.
On the other hand, it's a presentation issue, so it also makes sense to put it into the presentation layer.
For general OOP stuff, the object should not be exposing implementation details. I choose to interpret this as "avoid setters and getters when possible".
In the context of your question, I suggest that you have a getPriceDisplay() method that returns a string containing the formatted price.
The actual implementation of the formatting is hidden in the implementation details. You could provide a generic function for formatting, use some backend call, or something else. Those details should make no difference to the consumer of the 'Test' object.
Though it's not an OOP approach, in my opinion, this is a good time for an extension method. Call it .ToCurrency() which has the format of the currency...this could be taken from the Web.Config file if you wanted.
Edit
To elaborate, I would simply call .ToString("your-format") (of course this could be as simple as .ToString("C") for your specific question) in the extension method. This allows you change the format throughout the UI in one place. I have found this to be very useful when dealing with DateTime formats in web applications.
Wouldn't .ToString("C"); do the job? This would be in the presentation layer I would imagine.

Create a direct DATE or DATE/TIME input for iPhone apps

My users despise the iPhone native date/datetime pickers (spinning wheels). I need to come up with another solution such as a custom UITableViewCell that allows direct input or a UIAlertView that is customized for input similar to the way Android handles date and time input. I'll obviously need to validate the input as they input it to ensure it is a valid date and time input, as I'm using MonoTouch I suppose I'll use RegEx to validate.
Before I do all this work I'm looking for any feedback from others that may have tried this or references to other implementations so I can learn from someone that's already created a system such as this.
What suggestions do you have for handling date/time input on an iPhone/iPad app that does NOT use the native UIDateTimePicker?
Thank you.
I ported/created a Calendar controller that works pretty much like the calendar app. One previous app that I worked on used it and the users really liked it: https://github.com/escoz/monotouch-controls/blob/master/UICatalog/CalendarMonthViewController.cs
That doesn't address time input, but it might be worthy taking a look.

A detailed explaination of what is "wrong" with date handling in GWT

I have seen countless forum posts complaining of issues in GWT when handling dates. I am still very unclear as to what is "wrong" with the date handling, what special considerations need to be made, and when/where/why methods like Date.setMinutes(int minutes) should not be used.
Does anybody have feedback?
Way back in the beginning of Java (i.e., Java 1.0), the date/time api largely (solely?) consisted of the Date class. The Java folks were aware that it lacked robustness, so they added the Calendar class in Java 1.1 and tried to change the Date class into a value object by deprecating most of it. Unfortunately, the Calendar class itself wasn't very well thought-out (see here) and we're stuck with what many consider to be a monstrosity.
Bringing us up to today, GWT supports Date because, well... how can you live without dates?, but doesn't support Calendar/GregorianCalendar/TimeZone because it's so ugly and surely there has to be a better answer. Sadly, no one's thought of it in over 3 years as Calendar support was requested way back in January of 2007 and marked as planned by April 2008.
In short, go ahead and use the the deprecated Date methods in your GWT code, if that will work for what you need to do.
EDIT: GWT's CalendarUtil class might also come in handy.

ColdFusion 7/8 Varied Timezones

This problem makes me really sad. I'm working with a pretty archaic web application with an eclectic mix of programming languages. Previously, it stored any and all datetimes in a Datetime field in our MySQL database. Until now, everything has been done in server time, which happens to be US/Pacific. I was tasked with adding "Timezone functionality" to the application. I have been pretty successful with converting most of the application.
My only remaining problems are the use of ColdFusion specific datetime functions. There appears to be many lines of code that use some of these functions. My ideal situation would be to be able to adjust the timezone on my Application.cfm page and not need to worry about the timezone for any of these functions. I've done quite a bit of searching and I can't seem to find anything. Any help would be awesome! Please let me know if I can provide any more details.
see: How to handle timezones in CFML?

Documentation of the lesser know AS3 properties

Over the past three weeks, I have lost at least 120 man hours because of some lesser known functionality in ActionScript 3. One of the problems was that, with Internet Explorer, if there are too many messages sent through LocalConnections, it will slow the messages sent through, but in the standalone player and in Firefox, this threshold is significantly higher. Another was that the static values of a class are instantiated even if the member itself is not being used:
import path.to.FooClass;
private function thisIsNeverCalledButItEnsuresThatFooClassIsImported():void
{
var f:FooClass = new FooClass();
}
Since FooClass had a static reference to a Singleton, that Singleton was instantiated so when I loaded a Module which used that Singleton, it would bind to values in an unpredictable way.
Additional cases where things behave in an unexpected way:
MovieClip.addFrameScript
flash.trace.Trace as a class
int is a faster incrementer class, Number is faster for mathematics, and uint is incredibly slow.
PrintDataGrid, if it has only one page, needs to have an empty value appended to the end of its dataProvider
If you use try...catch around two LocalConnections and connect them to the same channel, you will force garbage collection without needing System.gc
So here's the question (and I'm sorry for omitting this in the original post), is there any consolidated documentation for this type of behavior anywhere? Is there any (even non-Adobe) documentation on these issues (websites, forums, books, ANYTHING)? I know that these things are definitely easy enough TO document, but has anyone done so?
If not, am I missing anything? Are there other issues which I should know about?
This kind of useful information is very often not "centralized". Moreover, what you are looking for is something related to the experience of the programmer (more than to official docs).
FYI, there are two other methods for ensuring a class is included.
#1 - This syntax is actually used in the Flex source code:
import path.to.FooClass; FooClass; // note double reference
public class References
{
// No references needed in this class
}
#2 - Use the includes command line argument
-includes path.to.FooClass
You can always submit your experience using the "feedback" section in the help. Unfortunately, this is less obvious than the link that used to be at the bottom of each page in the older help files (which also served the useful function of opening a browser window with the web version of that help page).
Adobe says that it incorporates the comments from previous versions of the help into new versions, but my own observation suggests that there are instances where it does not happen. However, that and the appropriate cookbook are still the best avenue for those who believe that this kind of information should be centralized.
Note that the whole purpose behind modules is to avoid compiling code multiple times, so importing FooClass kind of defeated the purpose. The problems you had in this instance are just one of the many that happen if you use Singletons, and it's unfortunate that the first official Framework, Cairngorm, encouraged their widespread use. Check out http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ .

Resources