What are the pros and cons, and which should I use?
QUESTION 2
MappedDate and MappedDateTime apparently were parsing via LiftRules in setFromAny, while buildSetStringValue etc. were using (Time)Helpers.toDate. Is there a reason not to change it? Or, should toDate use ConversionRules?
Thanks.
> David and all,
> QUESTION 1
> I'm working on issue #258. Here are two options for an overridable parser (applies to formatting too):
> 1. def parse(s: String): Box[Date] = ConversionRules.parseDate()(s)
> 2. def parse: String=>Box[Date] = ConversionRules.parseDate()
>
> What are the pros and cons, and which should I use?
I prefer 1) I see no reason for parse to be a function....
> QUESTION 2
> MappedDate and MappedDateTime apparently were parsing via LiftRules in setFromAny, while buildSetStringValue etc. were using (Time)Helpers.toDate. Is there a reason not to change it? Or, should toDate use ConversionRules?
I think it would be natural for toDate to use ConversionRules....then
ConversionRules becomes the only place where date formatting is handled.
/Jeppe
On 05/02/10 5:28 PM, Jeppe Nejsum Madsen wrote:
> Naftoli Gugenheim<nafto...@gmail.com> writes:
>
>> David and all,
>> QUESTION 1
>> I'm working on issue #258. Here are two options for an overridable parser (applies to formatting too):
>> 1. def parse(s: String): Box[Date] = ConversionRules.parseDate()(s)
>> 2. def parse: String=>Box[Date] = ConversionRules.parseDate()
>>
>> What are the pros and cons, and which should I use?
>
> I prefer 1) I see no reason for parse to be a function....
+1
Naftoli Gugenheim <nafto...@gmail.com> writes:
> David and all,
> QUESTION 1
> I'm working on issue #258. Here are two options for an overridable parser (applies to formatting too):
> 1. def parse(s: String): Box[Date] = ConversionRules.parseDate()(s)
> 2. def parse: String=>Box[Date] = ConversionRules.parseDate()
>
> What are the pros and cons, and which should I use?
I prefer 1) I see no reason for parse to be a function....
> QUESTION 2
> MappedDate and MappedDateTime apparently were parsing via LiftRules in setFromAny, while buildSetStringValue etc. were using (Time)Helpers.toDate. Is there a reason not to change it? Or, should toDate use ConversionRules?
I think it would be natural for toDate to use ConversionRules....then
ConversionRules becomes the only place where date formatting is handled.
/Jeppe
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Thanks!
-------------------------------------
> Any thoughts on this?
> Basically, to restate the questions in a different way.
> - I would like to add overridable methods to MappedDate/Time/DateTime, to allow controlling the way they parse and format strings.
> - Do I need a new 'format' method to controll conversion to a string? Maybe just leverage toString?
I think toString is fine
> - Until now there were two places in Mapped(Date)(Time) where parsing occurred. setFromAny used LiftRules.parseDate, while buildSetStringValue etc. used TimeHelpers.toDate.
Should use same mechanism
> - Do we need methods like setFromAny and TimeHelpers.toDate, which take an Any and pattern match on several types of inputs? Isn't that very un-typesafe?
> - Why the inconsistency between setFromAny and buildSetStringValue? Should both use ConversionRules? Should both use toDate which should use ConversionRules?
> - Should anything in TimeHelpers use ConversionRules? (After all, ConversionRules uses TimeHelpers, and two-way dependencies are probably undesirable.) Should ConversionRules be in util rather than webkit?
I don't know why things are as they are, but going forward, my assumption is
this:
- If I change date/time parsing in ConversionRules, this changes all the
places where "default" date/time parsing to/from the UI takes place
- I think this also goes for TimeHelpers. I see this as a higher level
abstraction (the Helpers) on lower level code (ConversionRules), not
the other way around
- There can be still be specific date formats (ie internetDate) that is
being used for API level formatting.
/Jeppe
-------------------------------------
Jeppe Nejsum Madsen<je...@ingolfs.dk> wrote:
> Wait--are you saying TimeHelpers should use ConversionRules and
> ConversionRules should *not* reference TimeHelpers?
I think so (without knowing too much about the code :-)
> If so it would involve a lot of refactoring,
In that case, suggest we postpone that bit :-)
> although I think I hear where you're coming from. I'll try to push
> the wip-nafg-date branch a bit later. What time zone are you in?
CET
/Jeppe
-------------------------------------
Jeppe Nejsum Madsen<je...@ingolfs.dk> wrote:
Naftoli Gugenheim <nafto...@gmail.com> writes:
CET
/Jeppe
--
> It would be really great if you could take a look at TimeHelpers and my diff (vs. original), on RB and wip-nafg-date.
I'll be glad to take a look, but not really sure what it is you want me
to look at :-)
> I asked about your time zone only because I was wondering if you'd be around when I pushed it, but it's pushed.
Ok, it's getting late here but I'll look tomorrow...
/Jeppe
-------------------------------------
Jeppe Nejsum Madsen<je...@ingolfs.dk> wrote:
Naftoli Gugenheim <nafto...@gmail.com> writes:
/Jeppe
--
> At what would make sense to move around, i.e., what I should to move #257 and #258 forward.
> Thanks!
I think those look good. In the spirit of incremental progress, I think
any other changes should be on new tickets.
/Jeppe
-------------------------------------
Jeppe Nejsum Madsen<je...@ingolfs.dk> wrote:
Naftoli Gugenheim <nafto...@gmail.com> writes:
/Jeppe
--
I'm not sure I follow? I can't find buildSetFromString (in master)
anywhere and the setFromAny that covers string seem to call
ConversionRules?
To summarize: I think all code in MappedDate/Time should go through
ConversionRules
/Jeppe
/Jeppe
It's getting late and I'm perhaps not thinking straight but I think
TimeHelpers.toDate should go through ConversionRules. This may cause
circular deps etc. in which case I think buildSetStringValue should go
through ConversionRules.
I don't know mapper internals good enough to really see through the
consequences, but from a user perspective, I think all conversions
should (in the end) go through ConversionRules.
/Jeppe
- Until now there were two places in Mapped(Date)(Time) where parsing occurred. setFromAny used LiftRules.parseDate, while buildSetStringValue etc. used TimeHelpers.toDate.
- Do we need methods like setFromAny and TimeHelpers.toDate, which take an Any and pattern match on several types of inputs? Isn't that very un-typesafe?
- Why the inconsistency between setFromAny and buildSetStringValue? Should both use ConversionRules? Should both use toDate which should use ConversionRules?