jason
I don't know why you object to magic numbers, Jason. I'm thinking this
difference between the mumps and pick epoch dates should go on my
gravestone as one of the defining numbers of my life. cheers! --dawn
> --
> You received this message because you are subscribed to the Google Groups
> "InterSystems: MV Community" group.
> To post to this group, send email to Cac...@googlegroups.com
> To unsubscribe from this group, send email to
> CacheMV-u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/CacheMV?hl=en
--
Dawn M. Wolthuis
Take and give some delight today
We're finding it easier to "pollute" our MV code with COS as we work on
our ZEN project. I will admit that I'm addicted to the code completion
and there are some really nice macros in COS (&js<>, &html<>, etc).
Also, $zconvert(var, "O", "HTML") solves some headaches when writing
database items to web pages. Because of this, I'm finding the need to
stuff $NOW() into MV.Dates and would love to have a "standard" way of
doing this.
Jason
PS - (4 / (6 / 3)) + (8 * 5) = 42, so I guess it IS a "magic" number...
Maybe I can make it equal 23 and get it into a movie also.
--
#Define MVDateNow ($p($h,",",1)-46385)
w "today is: "_$$$MVDateNow
the outer parens let you use it in an expression
Jason
On 2/23/2011 6:40 PM, Michael Cohen wrote:
> Does this snippet of COS code do what you want?
>
> #Define MVDateNow ($p($h,",",1)-46385)
> w "today is: "_$$$MVDateNow
>
> the outer parens let you use it in an expression
>
> -----Original Message-----
> From: intersy...@googlegroups.com [mailto:intersy...@googlegroups.com] On Behalf Of Dawn Wolthuis
> Sent: Wednesday, February 23, 2011 6:04 PM
> To: intersy...@googlegroups.com
> Subject: Re: [InterSystems-MV] Convert from Cache date to MV date
>
> Yeah, I could tell you decided to write source in mvbasic, cos, and
> javascript for Zen. I was trying to limit the general purpose
> programming languages to 2 (mvbasic and javascript) in addition to
> sql, cmql, xml, html, and css. Adding cos to the mix seemed like way
> too much of a learning curve for developers coming onto the project. I
> wish that instead we could have&html<> and such in mvbasic, but until
> then, those PRINT statements work their magic. cheers! --dawn
>
> On Wed, Feb 23, 2011 at 4:53 PM, Jason Warner<jas...@brashers.com> wrote:
>> Dawn,
>>
>> We're finding it easier to "pollute" our MV code with COS as we work on our
>> ZEN project. I will admit that I'm addicted to the code completion and there
>> are some really nice macros in COS (&js<>,&html<>, etc). Also,
s mvDate = ##class(%MV.Date).DateToLogical($piece($now(), ",", 1))
Jason
JASON:; crt date()
15761
JASON:[ w ##class(%MV.Date).DateToLogical($piece($now(), ",", 1))
15761
I would have thought that the only time the difference in "day 0" was
significant would be when you were converting an application, and more
importantly DATA .... once the data is actually converted, I wouldn't
have thought that ANYONE would give a damn what day zero is ... provided
they could convert from "an internal date", subtract 2 dates to get a
day difference. I would have thought it would be easier all around to
simply use whatever the "natural" day 0 of the system is.
If you were shuffling data back & forth between Cache & "real" MV
systems, then I could see a case, but to have to jump through hoops like
this seems a bit lame to me
Just my $0.02
Ross Ferris
Stamina Software
Visage > Better by Design!
>>>>> On Wed, Feb 23, 2011 at 3:24 PM, Jason
>Warner<jas...@brashers.com> wrote:
>>>>>> Is there a standard way on the system to convert from a Cache
date
>>>>>> (ie $piece($now(), ",", 1)) to an MV date without directly
>>>>>> subtracting 46385 from it? I keep forgetting the amount to
>>>>>> subtract from the Cache date and would like to avoid magic
numbers in
>my code.
>>>>>>
>>>>>> jason
>>>>>>
For example, in SQL there are CURDATE and CURRENT_DATE functions that
are documented as returning the current date. However it is the
current mumps date. So, you need to subtract the magic number.
The reason I once knew this number too well was because the projection
for AJAX/Zen did not initially work with the Zen components. So, for
example, I could not enter my birth date into the system because it
was a negative number and negative dates were not permitted (since
they are not in mumps).
The good news is that everything our team identified was addressed, so
we do very little mumps date/pick date gymnastics anymore other than
related to SQL queries with comparisons to the current date. Jason is
trying to work with pick dates through mumps code, where the utilities
are obviously directed to the mumps date instead.
I hope I said that accurately, else feel free to correct me.
So, yes, Ross, you are right that we are not caring about this
anymore, but in the evolution of the integration of MV with Zen and
SQL we have worked with this epoch date difference. --dawn
--
Because COS adds some niceness that we don't have in MV (and in some
cases the necessity of COS), MV developers have to grapple with the date
issue. Like Dawn said, there are still some instances where you still
have to know the magic number so that you can convert what you get from
Cache to something that MV understands. Intersystems has been very good
at solving these issues, but they still crop up from time to time.
Jason
>> If you were shuffling data back& forth between Cache& "real" MV
--dawn
--
So you're saying instead of:
ClassMethod zenAlert(message as %String) [ZenMethod, language=cache] {
&js< alert("#(message)#"); >
}
I can do this:
ClassMethod zenAlert(message as %String) [ZenMethod, language=mvbasic] {
print \alert("\ : message : \");\
}
And that goes back to the client? I guess that makes sense since most of
the macros get translated into writes with proper escaping behind the
scenes. I just assumed there was some more wiring that ZEN added when it
encounters the &js<> macro.
jason
On 2/25/2011 10:30 AM, Dawn Wolthuis wrote:
> Jason -- Instead of the&js<> in cos, we just do print statements in
> mvbasic. We have found that we rarely need to do this, but it is
> possible, just like the&html<> where we can do print statements
> instead.
>
> --dawn
>
> On Fri, Feb 25, 2011 at 11:06 AM, Jason Warner<jas...@brashers.com> wrote:
>> Dawn explained it very well. The issue we have is that we have a legacy MV
>> system with data and information in MV format. We are trying to "modernize"
>> it by adding a nice web interface to our data. Unfortunately, in Cache there
>> are some things that you have to do in COS. For example, in a ZenMethod, you
>> can use&js<> tags to send information to the client. I am not aware of a
>> way to do this in MVBASIC. We also find it easier to do any methods that
>> output HTML to the client in COS. The&html<> macros allow us to write pure
print "alert('hi " : coolVariable : " mom')"
at the end of a ZenMethod.
We try to keep all of our source code mvbasic both because we have
good mvbasic experience on the team (not me, but others), so that we
are not maintaining so many languages, and because we are storing
things in mv persistent classes. InterSystems has been good about
keeping sort-of-kinda to the statement that anything you can do in cos
you can do in mvbasic. The things that are hard for us are those dang
macros. We have learned to convert most other things we find in
examples and such. We thought we had it when we got one working by
calling cos with the macro in it from mvbasic, but then the next one
we could not get to function that way, so we have a few places where
we should be employing a macro and we don't or where we should be
writing mvbasic and we are not.
--dawn
--