Re: [flexcoders] Storing Dates Times in VO's
Kevin: I dont' use AMFPHP so I can't specifically help you with that situation, but to your first question: I would recommend figuring out a way to get your PHP DateTypes to automatically transfer to Date type's in Flex. I went down both roads (Date and String in flex) and found that there is a Date Type in Flex for a reason. It makes your life easier when dealing with Dates, especially comparing, sorting and performing Date arithmetic. So my recommendation would be to make the extra effort to get your Object to transfer correctly typed properties... Sam On 19 Mar 2007 17:51:09 -0700, Kevin [EMAIL PROTECTED] wrote: Should Dates Times be stored as Strings in Flex VO's? If not, what is the proper way to assign a value from the server (which generally comes in as a string) to a Date type in a Flex VO? I have been struggling with this. I am using AMFPHP and mapping my PHP objects to Flex for calls returned from the server, however, my date fields are not mapping. Does a setter function get call when you are doing VO mapping?? Thanks for the help. Thanks, Kevin
Re: [flexcoders] Storing Dates Times in VO's
I would store it in a format that both PHP and Flex understand and can manipulate (i.e. epoch milliseconds). That way you can convert it to either a PHP date object or a Flex date object for convenience when you need to. Cheers, Brian On 3/20/07, Sam Shrefler [EMAIL PROTECTED] wrote: Kevin: I dont' use AMFPHP so I can't specifically help you with that situation, but to your first question: I would recommend figuring out a way to get your PHP DateTypes to automatically transfer to Date type's in Flex. I went down both roads (Date and String in flex) and found that there is a Date Type in Flex for a reason. It makes your life easier when dealing with Dates, especially comparing, sorting and performing Date arithmetic. So my recommendation would be to make the extra effort to get your Object to transfer correctly typed properties... Sam On 19 Mar 2007 17:51:09 -0700, Kevin [EMAIL PROTECTED] wrote: Should Dates Times be stored as Strings in Flex VO's? If not, what is the proper way to assign a value from the server (which generally comes in as a string) to a Date type in a Flex VO? I have been struggling with this. I am using AMFPHP and mapping my PHP objects to Flex for calls returned from the server, however, my date fields are not mapping. Does a setter function get call when you are doing VO mapping?? Thanks for the help. Thanks, Kevin -- Brian Dunphy
Re: [flexcoders] Storing Dates Times in VO's
thanks for the advice. I completely agree that I need to store them as dates. Unfortunately, my problem seems to be how to do that from the PHP end of things. As I understand it, becuase PHP is not a typed language, AMFPHP tries to guess as what the type is. Unfortunately, I can't figure out how to force it to see a date type. It sees anything I send it as a string or number (UTC). Any suggestions from AMFPHP coders out there?? In the meantime here is what I am going to try: in PHP: send a VO with class myDate(){ public phpDate; // as a string } in FLEX: public class myDate(){ public phpDate:String; public function get flexDate():Date{ return new Date(phpDate); //parse PHP date (not sure how best to do this yet) } public function set flexDate(value:Date):void{ this.phpDate = value.toString; //or something like this... } } Hopefully this will work and be as clean as I can make it until I figure out how to return Date types from AMFPHP. Thanks, Kevin On Mar 20, 2007, at 8:20 AM, Brian Dunphy wrote: I would store it in a format that both PHP and Flex understand and can manipulate (i.e. epoch milliseconds). That way you can convert it to either a PHP date object or a Flex date object for convenience when you need to. Cheers, Brian On 3/20/07, Sam Shrefler [EMAIL PROTECTED] wrote: Kevin: I dont' use AMFPHP so I can't specifically help you with that situation, but to your first question: I would recommend figuring out a way to get your PHP DateTypes to automatically transfer to Date type's in Flex. I went down both roads (Date and String in flex) and found that there is a Date Type in Flex for a reason. It makes your life easier when dealing with Dates, especially comparing, sorting and performing Date arithmetic. So my recommendation would be to make the extra effort to get your Object to transfer correctly typed properties... Sam On 19 Mar 2007 17:51:09 -0700, Kevin [EMAIL PROTECTED] wrote: Should Dates Times be stored as Strings in Flex VO's? If not, what is the proper way to assign a value from the server (which generally comes in as a string) to a Date type in a Flex VO? I have been struggling with this. I am using AMFPHP and mapping my PHP objects to Flex for calls returned from the server, however, my date fields are not mapping. Does a setter function get call when you are doing VO mapping?? Thanks for the help. Thanks, Kevin -- Brian Dunphy
Re: [flexcoders] Storing Dates Times in VO's
my temporary solution using getters setters: example of a VO with Date Types: public var _lastDay: String; public var _clockedIn: String; //date getter setters public function get lastDay():Date{ return mysqlDateUtil.parseDate(this._lastDay); } public function get clockedIn():Date{ return mysqlDateUtil.parseDate(this._clockedIn); } public function set lastDay(value:Date):void{ this._lastDay; } public function set clockedIn(value:Date):void{ this._clockedIn; } PHP just passes in it's Mysql date string into the vars _lastDay _clockedIn. The only downside to this is that I can't seem to make the holder variables private since or else they don't get mapped from PHP. The mysqlDateUtil is a custom class I wrote to convert mysql date time stings into Flex dates. If anyone is interested I can share that code. It's a little sloppy, but it works for now. - Kevin On Mar 20, 2007, at 4:11 PM, Kevin wrote: thanks for the advice. I completely agree that I need to store them as dates. Unfortunately, my problem seems to be how to do that from the PHP end of things. As I understand it, becuase PHP is not a typed language, AMFPHP tries to guess as what the type is. Unfortunately, I can't figure out how to force it to see a date type. It sees anything I send it as a string or number (UTC). Any suggestions from AMFPHP coders out there?? In the meantime here is what I am going to try: in PHP: send a VO with class myDate(){ public phpDate; // as a string } in FLEX: public class myDate(){ public phpDate:String; public function get flexDate():Date{ return new Date(phpDate); //parse PHP date (not sure how best to do this yet) } public function set flexDate(value:Date):void{ this.phpDate = value.toString; //or something like this... } } Hopefully this will work and be as clean as I can make it until I figure out how to return Date types from AMFPHP. Thanks, Kevin On Mar 20, 2007, at 8:20 AM, Brian Dunphy wrote: I would store it in a format that both PHP and Flex understand and can manipulate (i.e. epoch milliseconds). That way you can convert it to either a PHP date object or a Flex date object for convenience when you need to. Cheers, Brian On 3/20/07, Sam Shrefler [EMAIL PROTECTED] wrote: Kevin: I dont' use AMFPHP so I can't specifically help you with that situation, but to your first question: I would recommend figuring out a way to get your PHP DateTypes to automatically transfer to Date type's in Flex. I went down both roads (Date and String in flex) and found that there is a Date Type in Flex for a reason. It makes your life easier when dealing with Dates, especially comparing, sorting and performing Date arithmetic. So my recommendation would be to make the extra effort to get your Object to transfer correctly typed properties... Sam On 19 Mar 2007 17:51:09 -0700, Kevin [EMAIL PROTECTED] wrote: Should Dates Times be stored as Strings in Flex VO's? If not, what is the proper way to assign a value from the server (which generally comes in as a string) to a Date type in a Flex VO? I have been struggling with this. I am using AMFPHP and mapping my PHP objects to Flex for calls returned from the server, however, my date fields are not mapping. Does a setter function get call when you are doing VO mapping?? Thanks for the help. Thanks, Kevin -- Brian Dunphy
[flexcoders] Storing Dates Times in VO's
Should Dates Times be stored as Strings in Flex VO's? If not, what is the proper way to assign a value from the server (which generally comes in as a string) to a Date type in a Flex VO? I have been struggling with this. I am using AMFPHP and mapping my PHP objects to Flex for calls returned from the server, however, my date fields are not mapping. Does a setter function get call when you are doing VO mapping?? Thanks for the help. Thanks, Kevin