Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
ซ Groups Home
Formatting a date
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ben Short  
View profile  
 More options Feb 23 2012, 3:34 pm
From: Ben Short <b...@benshort.co.uk>
Date: Thu, 23 Feb 2012 12:34:00 -0800 (PST)
Subject: Formatting a date
Hi,

I'm trying to format a unix epoc into a human readable date as shown
here https://community.jivesoftware.com/docs/DOC-42113#Formatting_Dates
but I get an error when I try to compile it.

My soy file:

{namespace nalps.map.mockup}
/**
* @param speedLimit
* @param name
* @param carCount
* @param peakSpeed
* @param averageSpeed
* @param temperature
* @param windSpeed
* @param windDirection
* @param lastUpdated
*/
{template .speedSign}
<table class="speed-sign-table">
    <tr>
        <td class="speed-sign-icon-cell">
            <img class="speed-sign-icon" src="images/
{$speedLimit}.png" />
        </td>
        <td>{$name}</td>
    </tr>
    <tr>
        <td colspan="2">Count: {$carCount}cpm</td>
    </tr>
    <tr>
        <td colspan="2">Peak: {$peakSpeed}mph</td>
    </tr>
    <tr>
        <td colspan="2">Average: {$averageSpeed}mph</td>
    </tr>
    {if $temperature}
    <tr>
        <td colspan="2">Temperature: {$temperature}&deg;C</td>
    </tr>
    {/if}
    {if $windSpeed}
    <tr>
        <td colspan="2">Wind speed: {$windSpeed}mph</td>
    </tr>
    {/if}
    {if $windDirection}
    <tr>
        <td colspan="2">Wind direction: {$windDirection}mph</td>
    </tr>
    {/if}
    <tr>
        <td colspan="2">Last updated:
{formatDate($lastUpdated,'long','date')}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td align="right"><a href="">Refresh</a></td>
    </tr>
</table>
{/template}

Compile output:

Exception in thread "main"
com.google.template.soy.base.SoySyntaxException: In file templates.soy:
46: Unrecognized function 'formatDate' (function call
"formatDate($lastUpdated, 'long', 'date')").
        at com.google.template.soy.parsepasses.CheckFunctionCallsVisitor
$CheckFunctionCallsExprVisitor.visitFunctionNode(CheckFunctionCallsVisitor. java:
173)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visit(AbstractExpr NodeVisitor.java:
114)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visit(AbstractExpr NodeVisitor.java:
69)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.visitChildren(Abstract NodeVisitor.java:
58)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visitChildren(Abst ractExprNodeVisitor.java:
127)
        at com.google.template.soy.parsepasses.CheckFunctionCallsVisitor
$CheckFunctionCallsExprVisitor.visitExprNode(CheckFunctionCallsVisitor.java :
125)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visitExprRootNode( AbstractExprNodeVisitor.java:
150)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visit(AbstractExpr NodeVisitor.java:
76)
        at
com.google.template.soy.exprtree.AbstractExprNodeVisitor.visit(AbstractExpr NodeVisitor.java:
69)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.exec(AbstractNodeVisit or.java:
39)
        at
com.google.template.soy.parsepasses.CheckFunctionCallsVisitor.visitSoyNode( CheckFunctionCallsVisitor.java:
89)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitPrintNode(Abstr actSoyNodeVisitor.java:
216)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
83)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
54)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.visitChildren(Abstract NodeVisitor.java:
58)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildren(Abstra ctSoyNodeVisitor.java:
121)
        at
com.google.template.soy.parsepasses.CheckFunctionCallsVisitor.visitSoyNode( CheckFunctionCallsVisitor.java:
102)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitTemplateNode(Ab stractSoyNodeVisitor.java:
160)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitTemplateBasicNo de(AbstractSoyNodeVisitor.java:
152)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
64)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
54)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.visitChildren(Abstract NodeVisitor.java:
58)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildren(Abstra ctSoyNodeVisitor.java:
121)
        at
com.google.template.soy.parsepasses.CheckFunctionCallsVisitor.visitSoyNode( CheckFunctionCallsVisitor.java:
102)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitSoyFileNode(Abs tractSoyNodeVisitor.java:
148)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
62)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
54)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.visitChildren(Abstract NodeVisitor.java:
58)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildren(Abstra ctSoyNodeVisitor.java:
121)
        at
com.google.template.soy.parsepasses.CheckFunctionCallsVisitor.visitSoyNode( CheckFunctionCallsVisitor.java:
102)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitSoyFileSetNode( AbstractSoyNodeVisitor.java:
144)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
61)
        at
com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNod eVisitor.java:
54)
        at
com.google.template.soy.basetree.AbstractNodeVisitor.exec(AbstractNodeVisit or.java:
39)
        at
com.google.template.soy.SoyFileSet.runMiddleendPasses(SoyFileSet.java:
792)
        at
com.google.template.soy.SoyFileSet.compileToJsSrcFiles(SoyFileSet.java:
733)
        at
com.google.template.soy.SoyToJsSrcCompiler.execMain(SoyToJsSrcCompiler.java :
255)
        at
com.google.template.soy.SoyToJsSrcCompiler.main(SoyToJsSrcCompiler.java:
205)

Am I missing an external lib or something?

Regards

Ben


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juan Mendes  
View profile  
 More options Feb 23 2012, 4:06 pm
From: Juan Mendes <mendesj...@gmail.com>
Date: Thu, 23 Feb 2012 13:06:03 -0800
Local: Thurs, Feb 23 2012 4:06 pm
Subject: Re: Formatting a date

It looks like Jive adds some custom functions, I've never seen formatDat.
Are you sure you're including the Jive plugins?

--Juan

--
Juan Mendes

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Short  
View profile  
 More options Feb 23 2012, 4:15 pm
From: Ben Short <b...@benshort.co.uk>
Date: Thu, 23 Feb 2012 21:15:34 +0000
Local: Thurs, Feb 23 2012 4:15 pm
Subject: Re: Formatting a date
Hi Juan,

I assumed that it was just better documentation for closure-templates
so I don't have the jive plugins.

Can I write a plugin? Do I just need to defined a function called
formatDate and it will be called?

Ben

On 23 February 2012 21:06, Juan Mendes <mendesj...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juan Mendes  
View profile  
 More options Feb 23 2012, 4:27 pm
From: Juan Mendes <mendesj...@gmail.com>
Date: Thu, 23 Feb 2012 13:27:52 -0800
Local: Thurs, Feb 23 2012 4:27 pm
Subject: Re: Formatting a date

Here's the page on how to write plugins

http://code.google.com/closure/templates/docs/plugins.html#functions

I haven't done it

Good luck,

--Juan

--
Juan Mendes

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Short  
View profile  
 More options Feb 23 2012, 4:28 pm
From: Ben Short <b...@benshort.co.uk>
Date: Thu, 23 Feb 2012 21:28:23 +0000
Local: Thurs, Feb 23 2012 4:28 pm
Subject: Re: Formatting a date
Thanks

On 23 February 2012 21:27, Juan Mendes <mendesj...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Venaglia  
View profile  
 More options Feb 28 2012, 11:49 pm
From: Ed Venaglia <evena...@gmail.com>
Date: Tue, 28 Feb 2012 20:49:07 -0800 (PST)
Local: Tues, Feb 28 2012 11:49 pm
Subject: Re: Formatting a date

The formatDate() function is one of many custom functions provided by Jive.
It looks like you are trying to compile using the stand alone soy compiler.
Jive compiles soy files internally and does not use the stand alone
compiler.   ...just wanted to clear that up.

I've written a few custom functions, all fairly simple. The steepest part
of the learning curve is around generating JavaScript in Java. I would
recommend using a third-party date formatting library on the browser to
handle the actual date formatting, then delegate to that in
computeForJsSrc(). That'll keep the Java code much simpler. That's what we
do.

Good luck.

-Ed-
Senior Software Engineer
Jive Software


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »