fork download
  1. #import( 'dart:html' );
  2.  
  3. main()
  4. {
  5. var today = new Date.now();
  6. var firstDay = new Date( today.year, today.month, 1);
  7. var lastDay = new Date( today.year, today.month+1, 1 ).subtract( const Duration(1) );
  8.  
  9. var calendar = new Element.html( '''
  10. <table class="calendar">
  11. <thead>
  12. <tr>
  13. <th class="mon weekday">月</th>
  14. <th class="tue weekday">火</th>
  15. <th class="wed weekday">水</th>
  16. <th class="the weekday">木</th>
  17. <th class="fri weekday">金</th>
  18. <th class="sat weekend">土</th>
  19. <th class="sun weekend">日</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. </tbody>
  24. </table>
  25. ''');
  26.  
  27. var createWeek = () {
  28. var week = new TableRowElement();
  29. for( var i=0; i<7; i++ ) week.nodes.add( new TableCellElement() );
  30. return week;
  31. };
  32. var currentDay = new Date( today.year, today.month, 1);
  33. var tbody = calendar.query( 'tbody' );
  34. var week;
  35. while( currentDay <= lastDay ) {
  36. if( currentDay.day == 1 || currentDay.weekday == Date.MON )
  37. tbody.nodes.add( (week = createWeek()) );
  38. week.nodes[ currentDay.weekday-1 ].addText( currentDay.day.toString() );
  39. currentDay = currentDay.add( const Duration(1) );
  40. }
  41.  
  42. document.query( 'body' ).nodes.add( calendar );
  43. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty