Click here to Skip to main content
15,892,298 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Programming Quiz Pin
ZurdoDev6-Nov-19 1:02
professionalZurdoDev6-Nov-19 1:02 
GeneralRe: Programming Quiz Pin
Jörgen Andersson6-Nov-19 2:04
professionalJörgen Andersson6-Nov-19 2:04 
GeneralRe: Programming Quiz Pin
ZurdoDev6-Nov-19 2:12
professionalZurdoDev6-Nov-19 2:12 
GeneralRe: Programming Quiz Pin
Jane's Diary7-Nov-19 11:22
Jane's Diary7-Nov-19 11:22 
GeneralRe: Programming Quiz Pin
Fernando Takeshi Sato6-Nov-19 12:08
professionalFernando Takeshi Sato6-Nov-19 12:08 
GeneralRe: Programming Quiz Pin
PIEBALDconsult5-Nov-19 9:16
mvePIEBALDconsult5-Nov-19 9:16 
GeneralRe: Programming Quiz Pin
EliaMelfior6-Nov-19 0:34
EliaMelfior6-Nov-19 0:34 
GeneralRe: Programming Quiz Pin
Stuart Dootson6-Nov-19 1:50
professionalStuart Dootson6-Nov-19 1:50 
In Haskell (because, of course Haskell!):
haskell
import Data.List.Split
import Data.Time.Calendar;
import Data.Time.Calendar.Compat;
import Data.Time.Calendar.Julian;
import Text.Printf

printMonth :: Integer -> Int -> IO ()
printMonth year month = printWeeks entriesInMonth
    where
        -- printWeeks chunks the month's entries into weeks & prints each week on a new line
        printWeeks days = mapM_ (putStrLn.unwords) (chunksOf 7 days)

        -- entriesInMonth concatenates the empty entries at the start of the month with the days
        entriesInMonth = startPadding ++ daysOfMonth

        -- daysOfMonth generates a list of days of the month as strings
        daysOfMonth = map (printf "%2d") [1..(julianMonthLength year month)]

        -- startPadding generates blank strings for each empty entry before day '1'
        startPadding = replicate blanksBeforeDay1 "  "

        -- blanksBeforeDay1 is the number of empty entries before day '1'
        blanksBeforeDay1 = (fromEnum $ dayOfWeek (fromJulian year month 1)) `mod` 7

which gives:
> printMonth 2019 12
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
> printMonth 20190 12
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
> printMonth 20190 11
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

[ETA] That's using the Julian calendar - the standard Gregorian calendar can be used by replacing the word 'julian' or 'Julian' with 'gregorian'/'Gregorian'. And yes, I should be able to remember which calendar we use Blush | :O [/ETA]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p


modified 6-Nov-19 8:41am.

GeneralRe: Programming Quiz Pin
Jörgen Andersson6-Nov-19 2:01
professionalJörgen Andersson6-Nov-19 2:01 
GeneralRe: Programming Quiz Pin
Stuart Dootson6-Nov-19 2:39
professionalStuart Dootson6-Nov-19 2:39 
GeneralRe: Programming Quiz Pin
Jörgen Andersson6-Nov-19 3:04
professionalJörgen Andersson6-Nov-19 3:04 
GeneralRe: Programming Quiz Pin
agolddog6-Nov-19 2:39
agolddog6-Nov-19 2:39 
GeneralRe: Programming Quiz Pin
StarNamer@work3-Dec-19 5:42
professionalStarNamer@work3-Dec-19 5:42 
JokeShe's a witch! Pin
honey the codewitch5-Nov-19 6:41
mvahoney the codewitch5-Nov-19 6:41 
GeneralRe: She's a witch! Pin
  Forogar  5-Nov-19 7:14
professional  Forogar  5-Nov-19 7:14 
GeneralRe: She's a witch! Pin
Mike Hankey5-Nov-19 7:26
mveMike Hankey5-Nov-19 7:26 
GeneralRe: She's a witch! Pin
jeron15-Nov-19 7:58
jeron15-Nov-19 7:58 
GeneralRe: She's a witch! Pin
RickZeeland5-Nov-19 7:38
mveRickZeeland5-Nov-19 7:38 
GeneralRe: She's a witch! Pin
dandy725-Nov-19 8:09
dandy725-Nov-19 8:09 
GeneralRe: She's a witch! Pin
Caslen5-Nov-19 22:40
Caslen5-Nov-19 22:40 
GeneralRe: She's a witch! Pin
Super Lloyd5-Nov-19 8:26
Super Lloyd5-Nov-19 8:26 
GeneralRe: She's a witch! Pin
User 110609795-Nov-19 8:34
User 110609795-Nov-19 8:34 
GeneralRe: She's a witch! Pin
kmoorevs5-Nov-19 11:43
kmoorevs5-Nov-19 11:43 
RantDUMB AI Pin
Nelek5-Nov-19 5:17
protectorNelek5-Nov-19 5:17 
GeneralRe: DUMB AI Pin
Rick York5-Nov-19 6:00
mveRick York5-Nov-19 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.