Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
How to set the next week start date

How to set the next week start date

2007-04-30       - By Rebhan, Gilbert
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Hi,


-----Original Message-----
From: Ninju Bohra [mailto:ninju_bohra@(protected)]
Sent: Monday, April 30, 2007 6:58 AM
To: Ant Users List
Subject: Re: How to set the next week start date

/*
Yeah...that's what happens when you tweak sample code to demonstrate
something...you always mix up something

With a unit="week" the offset should only be offset="1" (or maybe -1)
for next week.

The confusion you got on the sample you wrote (the bizzare date of
19/15/2007) comes from the lowercase 'mm' you used in your pattern
string....lowercase 'mm' is minutes, I believe you meant month which is
uppercase MM

You will notice that your 'month' value (19) matches the minutes value
09:19 PM
*/

Oops ;-)

you're right


so :

<script language="ruby">
   <![CDATA[
       t = Time.now
       puts t.strftime("actual date == %m.%d.%Y")
       x=t.strftime("%w").to_i-1

       thisweek = (t - x * 86400).strftime("%m.%d.%Y")
       $project.setProperty "thisweek",  thisweek

       lastweek = (t - x * 86400 - 7 * 86400).strftime("%m.%d.%Y")
       $project.setProperty "lastweek",  lastweek

       nextweek =  (t - x * 86400 + 7 * 86400).strftime("%m.%d.%Y")
       $project.setProperty "nextweek",  nextweek
   ]]>
   </script>

and :

<tstamp>
   <format property="thisweek" pattern="MM.dd.yyyy"
      offset="0" unit="week"/>
</tstamp>

<tstamp>
   <format property="lastweek" pattern="MM.dd.yyyy"
      offset="-1" unit="week"/>
</tstamp>

<tstamp>
   <format property="nextweek" pattern="MM.dd.yyyy"
      offset="1" unit="week"/>
</tstamp>


are giving the same result


Regards, Gilbert

----- Original Message ----
From: Gilbert Rebhan <ant@(protected)>
To: Ant Users List <user@(protected)>
Sent: Friday, April 27, 2007 3:33:59 PM
Subject: Re: How to set the next week start date


Hi,

Ninju Bohra wrote:
> Have you looked at the <tstamp> task
(http://ant.apache.org/manual/CoreTasks/tstamp.html)
>
> Maybe something like:
>
> <tstamp>
>       <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"
>               offset="7" unit="week"/>
>   </tstamp>

i tried that on Win2000, with jdk 1.5.0_11 ant 1.6.5

<project name="project" default="main">
 <target name="depends">
   <tstamp>
     <format property="touch.time" pattern="mm/dd/yyyy hh:mm aa"
         offset="7" unit="week"/>
   </tstamp>
 </target>

 <target name="main" depends="depends">
   <echo>
      Antversion == ${ant.version}
      Today == ${TODAY}

      $${touch.time} == ${touch.time}
    </echo>
 </target>
</project>

and it gave me
Buildfile: J:\eclipse_3_2\workspace\AntTest\tstamp.xml
depends:
main:
     [echo] Antversion == Apache Ant version 1.6.5 compiled on June 2
2005
     [echo] Today == April 27 2007
     [echo]
     [echo] ${touch.time} == 19/15/2007 09:19 PM
BUILD SUCCESSFUL
Total time: 156 milliseconds


hm, strange 19/15/2007 ??

i think you meant something like
<tstamp>
   <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"
         offset="-7" unit="day"/>
</tstamp>

or

<tstamp>
   <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"
         offset="7" unit="day"/>
</tstamp>


similar to the example from manual :

  <tstamp>
      <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"
              offset="-5" unit="hour"/>
  </tstamp>


but that gives him the actual date minus | plus 7 days.

> Also when you say 'set the current date' what does that mean?
> If you want to calculate what '7 days from now and set it to an ANT
> property'
>please look at the <tstamp> task otherwise please provide more
>explaination on what you need.

I thought the original poster was asking for

"...
the next weeks start date and last week start date
..."

because of that i suggested the <script> solution, where
he can choose, whether the start day of week = sunday or
monday.

Otherwise the </tstamp> would fit of course.

So he should provide some more details ;-)


Regards, Gilbert


>
> ----- Original Message ----
> From: Satheesh <satish@(protected)>
> To: Ant Users List <user@(protected)>
> Sent: Friday, April 27, 2007 4:51:12 AM
> Subject: How to set the next week start date
>
>
> Hi Guys, If i want to set the current date its possible in ANT , even
if i want a date which is some 'n' days after the current date, that
also is possible..
>
> I need a way to set the value of the next weeks start date and last
week start date using ANT.
>
> How can i achieve this///



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.