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     >>  


Seems like <tstamp unit=week ... />

assumes a week starts with monday, what if
you want the week to start with sunday ?!

Is that influenced from the locale settings

user.country | user.language ?


Gilbert

-----Original Message-----
From: Rebhan, Gilbert [mailto:Gilbert.Rebhan@(protected)]
Sent: Monday, April 30, 2007 8:49 AM
To: Ant Users List
Subject: RE: How to set the next week start date

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

---------------------------------------------------------------------
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.