For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.