Defining Weekdays for Calendar in Ruby

Aspose.Tasks - Defining Weekdays for Calendar

To Define Weekdays for Calendar using Aspose.Tasks Java for Ruby, simply invoke DefineWeekdaysForCalendar module. Here you can see example code.

 1project = Rjb::import('com.aspose.tasks.Project').new
 2cal = project.getCalendars().add("Calendar1")
 3weekday = Rjb::import('com.aspose.tasks.WeekDay')
 4dayType = Rjb::import('com.aspose.tasks.DayType')
 5cal.getWeekDays().add(weekday.createDefaultWorkingDay(dayType.Monday))
 6cal.getWeekDays().add(weekday.createDefaultWorkingDay(dayType.Tuesday))
 7cal.getWeekDays().add(weekday.createDefaultWorkingDay(dayType.Wednesday))
 8cal.getWeekDays().add(weekday.createDefaultWorkingDay(dayType.Thursday))
 9cal.getWeekDays().add(Rjb::import('com.aspose.tasks.WeekDay').new(dayType.Saturday))
10cal.getWeekDays().add(Rjb::import('com.aspose.tasks.WeekDay').new(dayType.Sunday))
11myWeekDay = Rjb::import('com.aspose.tasks.WeekDay').new(dayType.Friday)
12time1 = Rjb::import('com.aspose.tasks.WorkingTime').new
13calTime = Rjb::import('java.util.Calendar').getInstance()
14calTime.set(1,1,1,9,0,0)
15date = calTime.getTime()
16time1.setFromTime(date)
17calTime.set(1,1,1,12,0,0)
18date = calTime.getTime()
19time1.setToTime(date)
20time2 = Rjb::import('com.aspose.tasks.WorkingTime').new
21calTime.set(1,1,1,13,0,0)
22date = calTime.getTime()
23time2.setFromTime(date)
24calTime.set(1,1,1,16,0,0)
25date = calTime.getTime()
26time2.setToTime(date)
27myWeekDay.getWorkingTimes().add(time1)
28myWeekDay.getWorkingTimes().add(time2)
29myWeekDay.setDayWorking(true)
30cal.getWeekDays().add(myWeekDay)
31project.save("CalendarWeekdays.xml", Rjb::import('com.aspose.tasks.SaveFileFormat').XML)
32puts "Defined weekdays for calendar, please check the output file."

Download Running Code

Download Defining Weekdays for Calendar (Aspose.Tasks) from any of the below mentioned social coding sites:

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.