Year split in Quarters using basic jQuery

Posted by Alexander Corotchi on Stack Overflow See other posts from Stack Overflow or by Alexander Corotchi
Published on 2010-03-31T19:04:20Z Indexed on 2010/03/31 19:33 UTC
Read the original article Hit count: 443

Filed under:
|
|

Hi, I have a interesting question:

I want to split the year into 4 quarters. What is the idea,

A quarter can be different:

The HTML Code:

<div class="quarterBody">
    <span>04-29-2010</span>
    <span>06-29-2010</span>
    <span>08-29-2010</span>
</div>

jQuery (javascript) is total wrong, I hope that w:

       $(document).ready(function(){

            var quarter1 = to make interval (01-01-2010  to 03-31-2010);
            var quarter2 = to make interval (03-01-2010  to 06-31-2010);
            var quarter3 = to make interval (06-01-2010  to 09-31-2010);
            var quarter4 = to make interval (09-01-2010  to 12-31-2010);
                              ...

            $(".quarterBody span").each(function(){
                var date = Date.parse($(this).text());

                //to apply some magic code 

                $(this).addClass(quarterNumber);

            });
        });

OUTPUT:

<div class="quarterBody">
        <span class="Quarter1">02-29-2010</span>
        <span class="Quarter2">04-29-2010</span>
        <span class="Quarter3">08-29-2010</span>
             ...
    </div>

I know right now it is a stupid way, but I hope that somebody can help me, or suggest an idea how to do that in a better way!!

Thanks!

© Stack Overflow or respective owner

Related posts about date

Related posts about jQuery