# Create a progress bar indicating year progress

Your code has to output the percentage of the year already passed form 1st of January of the current year.

You have to display a progress bar and the figure.

# Input

You may use builtins to get the current date, if your language doesen't have it you can get date as input but it would be added to your byte count (has to ba a reasonable input format like 2017-05-12)

# Output

Bar status: At least 10 different status relating to figure.

Figure: can be rounded or float, has to represent current (or input) day of the year / 365(366) * 100

### Example

Today 2017-05-12

Output

▓▓▓▓▓░░░░░░░░░░ 36%

Take into account leap years informal definition (occurring evey 4 years) progess of the year for 12-Feb is 12% on leap years.

Inspiration

• Are we free to choose the characters? – Jonathan Allan May 12 '17 at 15:11
• you can use builtin date to get todays date or input date in an "adecuate" form (not unary). – marcosm May 12 '17 at 15:11
• @MarcosM "as long as [it] looks like a bar" is very unclear. – Leaky Nun May 12 '17 at 15:17
• @MarcosM This needs a tighter specification before it ready for main. Please could you address the issues raised? – Jonathan Allan May 12 '17 at 15:19
• "take into account leap years" This contradicts the question which states that a year should be considered to be 365 days. If we are taking leap years into account, do we need to do so properly? As in a leap year is one that is divisible by 4, unless it's also divisible by 100, unless it's also divisible by 400. – Shaggy May 12 '17 at 15:42

# PHP, 69 Bytes

for($p=date(z)/(364+date(L))*100^0;$i<100;)echo$i++>$p?_:Z;echo"$p%";  Try it online! date parameter z The day of the year (starting from 0) 0 through 365 parameter L Whether it's a leap year 1 if it is a leap year, 0 otherwise. PHP+HTML, 49 Bytes Non-Competenting <progress value=<?=date(z)?> max=<?=364+date(L)?>  add ></progress> if you don't want that the browser makes the rest Output for today in the snippet <progress value=131 max=364 # Fourier, 68 bytes Note, this has been invalidated by rule changes since it does not handle leap years 3d~D4d*30+D~s*100/365~p365(s>0{1}{9618asv~s}s{0}{9617a}i^~i)32apo37a  Try it in FourIDE! Outputs the bar like in the question but with 365 segments instead of 15. Makes the assumption that every year has 365 days and every month has 30 days. Output for today, 12th May: ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 36%  ## Explanation Firstly, it looks at the day part of the date and the month part of the month. To get how many days have come before this month, you multiply the month by 30. You then add the day to number of days. From that point, the calculations are academic and the only extra bytes are for drawing the bar. • How on earth did you answer 3 minutes ago when the question was closed 6 minutes ago? – Leaky Nun May 12 '17 at 15:25 • @LeakyNun If you don't refresh the page while the question is open, you can still answer on closed questions ;) – Beta Decay May 12 '17 at 15:27 • I thought this bug has been pointed out before I left (i.e. 9 months ago). – Leaky Nun May 12 '17 at 15:28 • Maybe it has been on the desktop site, but it still exists on mobile – Beta Decay May 12 '17 at 15:29 • "Each day has to display a different bar " – Jonathan Allan May 12 '17 at 16:04 # JavaScript (ES8), 1371351491551371231101081021009896 92 +7 bytes Requires new Date to be passed as an argument for an additional 7 bytes. n=>"=".repeat(v=(n-new Date(y=n.getFullYear(),0))/864e5/(y%4?3.65:3.66)|0).padEnd(100)+v+"%"  If we can't use spaces in the progress bar then 2 bytes will need to be added: n=>"1".repeat(v=(n-new Date(y=n.getFullYear(),0))/864e5/(y%4?3.65:3.66)|0).padEnd(100,0)+v+"%"  ## Try It o.innerText=(n=>"=".repeat(v=(n-new Date(y=n.getFullYear(),0))/864e5/(y%4?3.65:3.66)|0).padEnd(100)+v+"%")(new Date) <pre id=o> • "Each day has to display a different bar " – Jonathan Allan May 12 '17 at 16:05 • @Shaggy Turns out it was there from the start, just buried in the question... I wish it wasn't there though :P – Beta Decay May 12 '17 at 16:16 # Ruby, 72+7 = 79 bytes Uses -rdate flag. -1 byte from Tutleman. t=Date.today;d=t.yday;e=t.leap??366:365;$><<?=*d+?-*(e-d)+" #{d*100/e}%"


Today's output (2017-05-17):

=========================================================================================================================================------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 37%

• If I understand it correctly, you check with December 31st of the previous year, but this does not work for leap years. Dec 31st, 2016 is yday 366. – G B May 17 '17 at 14:12
• If you use Date instead of Time, you can shave off a chunk of bytes using Date#leap? to check if it's a leap year, even after accounting for the -rdate flag. Also, you may be able to use String#ljust to shorten the number of bit where you add the dashes. – Tutleman May 17 '17 at 15:01
• @GB yeah it seems I forgot the +1 on the year. The other comment meant I could take that check out anyways, though! – Value Ink May 17 '17 at 19:51
• @Tutleman great! -1 byte, although I guess it would've been -3 because of my other mistake with the leap year check. ljust is too long, though; I lose 5 bytes using it. – Value Ink May 17 '17 at 19:52

# C#, 133 bytes

using static System.DateTime;int k=Now.DayOfYear*100/(IsLeapYear(Now.Year)?366:365);()=>\$" {k}%".PadLeft(103-k,'-').PadLeft(103,'@');


Uses '@' and '-' Symbols

## Python 2, 134 bytes

Too long built-ins(

Try it online

from datetime import*
D=datetime
N=D.now()
Y=D(N.year,1,1)
P=100*(N-Y).days/-~(D(N.year,12,31)-Y).days
print'H'*P+'-'*(100-P)+'%s%%'%P


This line evaluates length of the current year to handle leap ones:

-~(D(N.year,12,31)-Y).days


# Python 2, 91 bytes

from time import*
t=gmtime()
d=t.tm_yday
n=365+(t.tm_year%4<1)
print'#'*d+'-'*(n-d),d/.01/n


Progress bar is 366 characters long on the pseudo-leap years (from the specification) and 365 on others, but uses the actual day count as a numerator (so it will have precision errors on century non-leap years). This could be fixed with y=t.tm.year;n=[y%4,y%100,y%400].count(0)%2 in place of n=365+(t.tm_year%4<1)

Try it online! (added tomorrow's output for comparison using extra code in the footer)

# Excel, 159 bytes

Relevant Quote:

=LEFT(REPT("|",10*(Now()-DATE(YEAR(Now()),1,0))/(365+(MOD(YEAR(Now()),4)=0)))&"::::::::::",10) & 100*(Now()-DATE(YEAR(Now()),1,0))/(365+(MOD(YEAR(Now()),4)=0))


Example Output:

|||:::::::38.0821917808219


Note that the progress bar rounds down because of how REPT works.

If using multiple cells is acceptable (I would tend to say it's not), an alternative answer is 97 bytes.

A1: =YEAR(NOW())
A2: =10*(NOW()-DATE(A1,1,0))/(365+(MOD(A1,4)=0))
A3: =LEFT(REPT("|",A2)&"::::::::::",10)&10*A2

# CJam, 75 bytes

et3<~@[sS+2m<~e|4%!:L28+T31@"\x1F\x1E\x1F\x1E\x1F\x1F\x1E\x1F\x1E\x1F":i~]@<:++e2 365L+/_'#*100'_*.e<S@'%


The bar goes up to 100, so it's a straight percentage bar.

The code for detecting leap years has been "borrowed" from Dennis's answer on another challenge.

The code contains several unprintable characters. They have been replaced by hex codes like \x1F in this answer.

Try it online!

Explanation

et                e# Get the date/time.
3<~               e# Get the first three elements ([year month day]) and dump it on the stack.
@                 e# Bring the year to the top.
[                 e# Begin an array:
sS+2m<~e|4%!     e#  Check if the current year is a leap year, returning 0 or 1.
:L               e#  Save the result in L.
28+              e#  Add it to 28.
T31@             e#  Push 0 and 31, bring (28 or 29) to the top.
e#    The 0 is there because you can't reduce an empty array (later...).
"..........":i~  e#  Dump the char codes of the unprintable string into the array.
]                 e# Close array. This now contains the length of each month.
@                 e# Bring the month to the top.
<                 e# Slice the array before the month, to get only those that have passed.
:+                e# Sum the days in those months.
+                 e# Add that sum to the day of the month.
e2                e# Multiply the result by 100.
365L+/            e# Divide by 365+L to get the percentage.
_'#*              e# Duplicate it, and repeat '#' that many times.
100'_*            e# Push a string containing 100 underscores.
.e<               e# Superimpose the hashes onto the underscores.
S@'%              e# Push a space, bring the percentage to the top, and push '%'.