For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho Deluge: Calculate start and end of Daylight Savings Time

What?
An article to document how I calculated the start and end dates of when Daylight Savings Time is in effect.

Why?
Admittedly, most of Zoho apps have this built-in but here's some snippets of code in case you need them.

How?
I will use this to amend and refine but here's the snippets for the various DSTs around the world.

US (Except Arizona, Hawaii and US Territories?):
  • DST Start Starts Second Sunday in March at 2:00
  • DST End Ends First Sunday in November at 2:00
copyraw
//
// Starts Second Sunday in March at 2:00
v_FirstMonthDate = toTime(zoho.currentdate.toString("yyyy") + "-03-08 02:00:00");
//
// Ends First Sunday in November at 2:00
v_LastMonthDate = toTime(zoho.currentdate.toString("yyyy") + "-11-01 02:00:00");
//
// loop through each day in a week to get the start and end dates
for each v_DayIndex in {0,1,2,3,4,5,6}
{
    v_CheckDateStart = v_FirstMonthDate.addDay(v_DayIndex);
    if(v_CheckDateStart.toString("E")=="Sun")
    {
        v_DST_StartTime = v_CheckDateStart;
    }
    v_CheckDateEnd = v_LastMonthDate.addDay(v_DayIndex);
    if(v_CheckDateEnd.toString("E")=="Sun")
    {
        v_DST_EndTime = v_CheckDateEnd;
    }
}	
info "Start Date (Current Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm");
info "End Date (Current Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm");
//
// Starts Second Sunday in March at 2:00
v_FirstMonthDate = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-03-08 02:00:00");
//
// Ends First Sunday in November at 2:00
v_LastMonthDate = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-11-01 02:00:00");
//
// loop through each day in a week to get the start and end dates
for each v_DayIndex in {0,1,2,3,4,5,6}
{
    v_CheckDateStart = v_FirstMonthDate.addDay(v_DayIndex);
    if(v_CheckDateStart.toString("E")=="Sun")
    {
        v_DST_StartTime = v_CheckDateStart;
    }
    v_CheckDateEnd = v_LastMonthDate.addDay(v_DayIndex);
    if(v_CheckDateEnd.toString("E")=="Sun")
    {
        v_DST_EndTime = v_CheckDateEnd;
    }
}	
info "Start Date (Next Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm");
info "End Date (Next Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm");
  1.  // 
  2.  // Starts Second Sunday in March at 2:00 
  3.  v_FirstMonthDate = toTime(zoho.currentdate.toString("yyyy") + "-03-08 02:00:00")
  4.  // 
  5.  // Ends First Sunday in November at 2:00 
  6.  v_LastMonthDate = toTime(zoho.currentdate.toString("yyyy") + "-11-01 02:00:00")
  7.  // 
  8.  // loop through each day in a week to get the start and end dates 
  9.  for each v_DayIndex in {0,1,2,3,4,5,6} 
  10.  { 
  11.      v_CheckDateStart = v_FirstMonthDate.addDay(v_DayIndex)
  12.      if(v_CheckDateStart.toString("E")=="Sun") 
  13.      { 
  14.          v_DST_StartTime = v_CheckDateStart; 
  15.      } 
  16.      v_CheckDateEnd = v_LastMonthDate.addDay(v_DayIndex)
  17.      if(v_CheckDateEnd.toString("E")=="Sun") 
  18.      { 
  19.          v_DST_EndTime = v_CheckDateEnd; 
  20.      } 
  21.  } 
  22.  info "Start Date (Current Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm")
  23.  info "End Date (Current Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm")
  24.  // 
  25.  // Starts Second Sunday in March at 2:00 
  26.  v_FirstMonthDate = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-03-08 02:00:00")
  27.  // 
  28.  // Ends First Sunday in November at 2:00 
  29.  v_LastMonthDate = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-11-01 02:00:00")
  30.  // 
  31.  // loop through each day in a week to get the start and end dates 
  32.  for each v_DayIndex in {0,1,2,3,4,5,6} 
  33.  { 
  34.      v_CheckDateStart = v_FirstMonthDate.addDay(v_DayIndex)
  35.      if(v_CheckDateStart.toString("E")=="Sun") 
  36.      { 
  37.          v_DST_StartTime = v_CheckDateStart; 
  38.      } 
  39.      v_CheckDateEnd = v_LastMonthDate.addDay(v_DayIndex)
  40.      if(v_CheckDateEnd.toString("E")=="Sun") 
  41.      { 
  42.          v_DST_EndTime = v_CheckDateEnd; 
  43.      } 
  44.  } 
  45.  info "Start Date (Next Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm")
  46.  info "End Date (Next Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm")
Yields:
copyraw
Start Date (Current Year): Sunday, 2021-03-14 02:00
End Date (Current Year): Sunday, 2021-11-07 02:00
Start Date (Next Year): Sunday, 2022-03-13 02:00
End Date (Next Year): Sunday, 2022-11-06 02:00
  1.  Start Date (Current Year): Sunday, 2021-03-14 02:00 
  2.  End Date (Current Year): Sunday, 2021-11-07 02:00 
  3.  Start Date (Next Year): Sunday, 2022-03-13 02:00 
  4.  End Date (Next Year): Sunday, 2022-11-06 02:00 


Europe:
  • DST Start Last Sunday in March at 1:00 UTC
  • DST End Last Sunday in October at 1:00 UTC
copyraw
//
// Starts Last Sunday in March at 1:00 UTC
v_FromMonthDate1 = toTime(zoho.currentdate.toString("yyyy") + "-04-01 01:00:00");
//
// Ends Last Sunday in October at 1:00 UTC
v_ToMonthDate1 = toTime(zoho.currentdate.toString("yyyy") + "-10-31 01:00:00");
//
// loop through each day in a week to get the start and end dates
for each v_DayIndex in {0,1,2,3,4,5,6}
{
    v_CheckDateStart = v_FromMonthDate1.subDay(v_DayIndex);
    if(v_CheckDateStart.toString("E")=="Sun")
    {
        v_DST_StartTime = v_CheckDateStart;
    }
    v_CheckDateEnd = v_ToMonthDate1.subDay(v_DayIndex);
    if(v_CheckDateEnd.toString("E")=="Sun")
    {
        v_DST_EndTime = v_CheckDateEnd;
    }
}	
//
// output
info "Start Date (Current Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm");
info "End Date (Current Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm");
//
// *********************************************************
//
// Starts Last Sunday in March at 1:00 UTC
v_FromMonthDate1 = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-04-01 01:00:00");
//
// Ends Last Sunday in October at 1:00 UTC
v_ToMonthDate1 = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-10-31 01:00:00");
//
// loop through each day in a week to get the start and end dates
for each v_DayIndex in {0,1,2,3,4,5,6}
{
    v_CheckDateStart = v_FromMonthDate1.subDay(v_DayIndex);
    if(v_CheckDateStart.toString("E")=="Sun")
    {
        v_DST_StartTime = v_CheckDateStart;
    }
    v_CheckDateEnd = v_ToMonthDate1.subDay(v_DayIndex);
    if(v_CheckDateEnd.toString("E")=="Sun")
    {
        v_DST_EndTime = v_CheckDateEnd;
    }
}	
info "Start Date (Next Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm");
info "End Date (Next Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm");
  1.  // 
  2.  // Starts Last Sunday in March at 1:00 UTC 
  3.  v_FromMonthDate1 = toTime(zoho.currentdate.toString("yyyy") + "-04-01 01:00:00")
  4.  // 
  5.  // Ends Last Sunday in October at 1:00 UTC 
  6.  v_ToMonthDate1 = toTime(zoho.currentdate.toString("yyyy") + "-10-31 01:00:00")
  7.  // 
  8.  // loop through each day in a week to get the start and end dates 
  9.  for each v_DayIndex in {0,1,2,3,4,5,6} 
  10.  { 
  11.      v_CheckDateStart = v_FromMonthDate1.subDay(v_DayIndex)
  12.      if(v_CheckDateStart.toString("E")=="Sun") 
  13.      { 
  14.          v_DST_StartTime = v_CheckDateStart; 
  15.      } 
  16.      v_CheckDateEnd = v_ToMonthDate1.subDay(v_DayIndex)
  17.      if(v_CheckDateEnd.toString("E")=="Sun") 
  18.      { 
  19.          v_DST_EndTime = v_CheckDateEnd; 
  20.      } 
  21.  } 
  22.  // 
  23.  // output 
  24.  info "Start Date (Current Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm")
  25.  info "End Date (Current Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm")
  26.  // 
  27.  // ********************************************************* 
  28.  // 
  29.  // Starts Last Sunday in March at 1:00 UTC 
  30.  v_FromMonthDate1 = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-04-01 01:00:00")
  31.  // 
  32.  // Ends Last Sunday in October at 1:00 UTC 
  33.  v_ToMonthDate1 = toTime(zoho.currentdate.addYear(1).toString("yyyy") + "-10-31 01:00:00")
  34.  // 
  35.  // loop through each day in a week to get the start and end dates 
  36.  for each v_DayIndex in {0,1,2,3,4,5,6} 
  37.  { 
  38.      v_CheckDateStart = v_FromMonthDate1.subDay(v_DayIndex)
  39.      if(v_CheckDateStart.toString("E")=="Sun") 
  40.      { 
  41.          v_DST_StartTime = v_CheckDateStart; 
  42.      } 
  43.      v_CheckDateEnd = v_ToMonthDate1.subDay(v_DayIndex)
  44.      if(v_CheckDateEnd.toString("E")=="Sun") 
  45.      { 
  46.          v_DST_EndTime = v_CheckDateEnd; 
  47.      } 
  48.  } 
  49.  info "Start Date (Next Year): " + v_DST_StartTime.toString("EEEE, yyyy-MM-dd HH:mm")
  50.  info "End Date (Next Year): " + v_DST_EndTime.toString("EEEE, yyyy-MM-dd HH:mm")
Yields:
copyraw
Start Date (Current Year): Sunday, 2021-03-28 01:00
End Date (Current Year): Sunday, 2021-10-31 01:00
Start Date (Next Year): Sunday, 2022-03-27 01:00
End Date (Next Year): Sunday, 2022-10-30 01:00
  1.  Start Date (Current Year): Sunday, 2021-03-28 01:00 
  2.  End Date (Current Year): Sunday, 2021-10-31 01:00 
  3.  Start Date (Next Year): Sunday, 2022-03-27 01:00 
  4.  End Date (Next Year): Sunday, 2022-10-30 01:00 

Additional Note(s):
  • This has not been tested extensively. Do not use if you are unsure it is calculating correctly. I use these to store the values in a table that can be double-checked at a later date.

Source(s):
Category: Zoho :: Article: 791

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2022 Joel Lipman .com. All Rights Reserved.