Dynamic SlotDuration in TimeLine View of RadScheduler - asp.net

In RadScheduler [TimeLine View], I have a StartDate = 1st Jan 2014 and EndDate = 30th April 2014 [both inclusive] and I have set the SlotDuration = 31 days.
I need to display 4 (January, February, March, April) slots [i.e. Number Of Slots = no of months between StartDate and EndDate taking above Dates into consideration] in TimeLine View and SlotDuration for each slot needs to be no. of days present in that month.
For January, SlotDuration = 31 [because January has 31 days]
February, SlotDuration = 28 [because February has 28 days or 29 if it's a Leap Year]
March, SlotDuration = 31 [because March has 31 days]
April, SlotDuration = 30 [because April has 30 days]
Case 1:
When I plot an appointment from 1 March 2014 to 31 March 2014, it should start and end in March slot but it starts from February slot because we have set SlotDuration = 31 days and February 2014 has only 28 days.
To fulfill 31 days slot duration, 1st, 2nd and 3rd of March are pushed to February 2014 slot.
Case 2:
When I plot an appointment from 4 March 2014 to 31 March 2014 it starts from March slot which is correct. But March slot also contains 1st, 2nd, and 3rd of April to fulfill 31 days slot duration.
My question is how do I make SlotDuration dynamic for each slot?
Currently, For Case 1 RadScheduler displays my appointment like in TimeLineMonth_Incorrect.png but i want to display it as in TimeLineMonth_Correct.png

Related

I want To find the number of weeks with start date and end date of each for the month using moment.js

let currentDate = moment();
let weekStart = currentDate.clone().startOf('week');
let weekEnd = currentDate.clone().endOf('week');
I want to know the start date and end date of every week for a given month.
expected output
In August month
In Array of object
1. 1 Aug 2021 - 7 Aug 2021
2. 8 Aug 2021 - 14 Aug 2021
3. 15 Aug 2021 - 21 Aug 2021
4. 22 Aug 2021 - 28 Aug 2021
5. 29 Aug 2021 - 31 Aug 2021
moment().startOf('week');
moment().endOf('week');
Refrence:
https://www.itsolutionstuff.com/post/moment-js-get-current-week-start-and-end-date-exampleexample.html

Converting UTC Time to Local Time with Days of Week and Date Included

I have the following 2 columns as part of a larger data frame. The Timezone_Offset is the difference in hours for the local time (US West Coast in the data I'm looking at). In other words, UTC + Offset = Local Time.
I'm looking to convert the UTC time to the local time, while also correctly changing the day of the week and date, if necessary. For instance, here are the first 5 rows of the two columns.
UTC Timezone_Offset
Sun Apr 08 02:42:03 +0000 2012 -7
Sun Jul 01 03:27:20 +0000 2012 -7
Wed Jul 11 04:40:18 +0000 2012 -7
Sat Nov 17 01:31:36 +0000 2012 -8
Sun Apr 08 20:50:30 +0000 2012 -7
Things get tricky when the day of the week and date also have to be changed. For instance, looking at the first row, the local time should be Sat Apr 07 19:42:03 +0000 2012. In the second row, the month also has to be changed.
Sorry, I'm fairly new to R. Could someone possibly explain how to do this? Thank you so much in advance.
Parse as UTC, then apply the offset in seconds, ie times 60*60 :
data <- read.csv(text="UTC, Timezone_Offset
Sun Apr 08 02:42:03 +0000 2012, -7
Sun Jul 01 03:27:20 +0000 2012, -7
Wed Jul 11 04:40:18 +0000 2012, -7
Sat Nov 17 01:31:36 +0000 2012, -8
Sun Apr 08 20:50:30 +0000 2012, -7", stringsAsFactors=FALSE)
data$pt <- as.POSIXct(strptime(data$UTC, "%a %b %d %H:%M:%S %z %Y", tz="UTC"))
data$local <- data$pt + data$Timezone_Offset*60*60
Result:
> data[,3:4]
pt local
1 2012-04-08 02:42:03 2012-04-07 19:42:03
2 2012-07-01 03:27:20 2012-06-30 20:27:20
3 2012-07-11 04:40:18 2012-07-10 21:40:18
4 2012-11-17 01:31:36 2012-11-16 17:31:36
5 2012-04-08 20:50:30 2012-04-08 13:50:30
>

Long string date to short date R

I have a df with dates formatted in the following way.
Date Year
<chr> <dbl>
Sunday, Jul 27 2008
Tuesday, Jul 29 2008
Wednesday, July 31 (1) 2008
Wednesday, July 31 (2) 2008
Is there a simple way to achieve the following format of columns and values? I'd also like to remove the (1) and (2) notations on the two July 31 dates.
Date Year Month Day Day_of_Week
2008-07-27 2008 07 27 Sunday
With base R, you can do:
dat <- data.frame(
Date = c("Sunday, Jul 27" ,"Tuesday, Jul 29", "Wednesday, July 31", "Wednesday, July 31"),
Year = rep(2008, 4),
stringsAsFactors = FALSE
)
dts <- as.POSIXlt(paste(dat$Year, dat$Date), format = "%Y %A, %B %d")
POSIXlt provides a list-based reference for the date/time. To see them, try unclass(dts[1]).
From here it can be rather academic:
dat$Month = 1 + dts$mon # months are 0-based in POSIXlt
dat$Day = dts$mday
dat$Day_of_Week = weekdays(dts)
dat
# Date Year Month Day Day_of_Week
# 1 Sunday, Jul 27 2008 7 27 Sunday
# 2 Tuesday, Jul 29 2008 7 29 Tuesday
# 3 Wednesday, July 31 2008 7 31 Thursday
# 4 Wednesday, July 31 2008 7 31 Thursday
library(dplyr)
library(lubridate)
dat = data_frame(date = c('Sunday, Jul 27','Tuesday, Jul 29', 'Wednesday, July
31 (1)','Wednesday, July 31 (2)'), year=rep(2008,4))
dat %>%
mutate(date = gsub("\\s*\\([^\\)]+\\)","",as.character(date)),
date = parse_date_time(date,'A, b! d ')) -> dat1
year(dat1$date) <- dat1$year
# A tibble: 4 × 2
date year
<dttm> <dbl>
1 2008-07-27 2008
2 2008-07-29 2008
3 2008-07-31 2008
4 2008-07-31 2008

I got different language result in r

If I write code like
everyday = seq(from=as.Date('2005-1-1'), to=as.Date('2005-12-31'), by='day')
cmonth = format(everyday, '%B')
table(cmonth)
cmonth
10월 11월 12월 1월 2월 3월 4월 5월 6월 7월 8월 9월
31 30 31 31 28 31 30 31 30 31 31 30
I get result in korean, but i want
October November December January February March ...
like this in eng. how can i change that

Access 2010 calculating the number of workdays

I am new to Access 2010 and need to get the number of days in a workweek excluding Holidays however with a twist. I have been able to use the standard VB code for workdays that appears on the internet and it works great for a simple Monday – Friday or Monday - Saturday calculation. My question is, how can I or is it possible to manipulate this code to calculate the number of days if Friday, Saturday and Sunday all count as 1 day?
Example: Calculate the number of days from Tuesday 11/25/14 to today.
-Today's date = Monday, December 01, 2014;
-Monday, December 01, 2014 = 0;
-Sunday, November 30, 2014 = 3;
-Saturday, November 29, 2014 = 3;
-Friday, November 28, 2014 = 3;
-Thursday, November 27, 2014(Holiday) = 2;
-Wednesday, November 26, 2014 = 2;
-Tuesday, November 25, 2014 = 1
So in the example above, the number of days would be 3.
If you need to account for Statutory Holidays you'll really need to use some kind of table. Purely algorithmic approaches to the problem are difficult to manage and prone to failure, primarily because
Holidays that fall on a fixed date may be observed on some other date. For example, if Christmas falls on a Saturday then employees may get a day off on Friday.
Some holiday dates are difficult to calculate. In particular, Good Friday is defined (here in Canada, at least) as "the Friday before the first Sunday after the first full moon following the Spring Equinox".
In its simplest form, the [DatesTable] could look something like this:
theDate dayOff comment
---------- ------ ----------------
2014-11-21 False
2014-11-22 True Saturday
2014-11-23 True Sunday
2014-11-24 False
2014-11-25 False
2014-11-26 False
2014-11-27 True Thanksgiving Day
2014-11-28 False
2014-11-29 True Saturday
2014-11-30 True Sunday
2014-12-01 False
2014-12-02 False
Counting the number of work days between 2014-11-25 and 2014-11-30 (inclusive) would simply be
SELECT COUNT(*) AS WorkDays
FROM DatesTable
WHERE theDate Between #2014-11-25# And #2014-11-30#
AND dayOff=False;

Resources