function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
samsam 

Timezone test class

 public static DateTime addDays(DateTime input, integer days, string timezoneSidId) {
        DateTime result = input.addDays(days);
        Timezone tz = Timezone.getTimezone(timezoneSidId);
        integer inputOffset = tz.getOffset(input) / 60000;
        integer resultOffset = tz.getOffset(result) / 60000;
        result = result.addMinutes(inputOffset - resultOffset);

        return result;
    }

    public static DateTime addMonths(DateTime input, integer months, string timezoneSidId) {
        DateTime result = input.addMonths(months);
        Timezone tz = Timezone.getTimezone(timezoneSidId);
        integer inputOffset = tz.getOffset(input) / 60000;
        integer resultOffset = tz.getOffset(result) / 60000;
        result = result.addMinutes(inputOffset - resultOffset);

        return result;
    }

    public static DateTime addYears(DateTime input, integer years, string timezoneSidId) {
        DateTime result = input.addYears(years);
        Timezone tz = Timezone.getTimezone(timezoneSidId);
        integer inputOffset = tz.getOffset(input) / 60000;
        integer resultOffset = tz.getOffset(result) / 60000;
        result = result.addMinutes(inputOffset - resultOffset);

        return result;
    }

    public static Date getDate(DateTime input, string timezoneSidId) {
        string dateIsoString = input.format(DATE_ISO_FORMAT, timezoneSidId);
        return getDateFromIsoString(dateIsoString);
    }

    // isoString should have the format yyyy-MM-dd
    public static Date getDateFromIsoString(string isoString) {
        return (Date)Json.deserialize('"' + isoString + '"', Date.class);
    }

    public static DateTime getDateTimeFromIsoString(string isoString) {
        return (DateTime)Json.deserialize('"' + isoString + '"', DateTime.class);
    }

    // Get 12:00:00 am from the input isoString date
    public static DateTime getStartOfDate(String isoString, string timezoneSidId) {
        return getStartOfDate(getDateFromIsoString(isoString), timezoneSidId);
        
    }
 
SwethaSwetha (Salesforce Developers) 
HI Sam,
The code provided in question does not highlight the uncovered lines.The below articles give a good insight into how coverage can be improved
 
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines 
 
Examples of timezone test classes:
https://salesforce.stackexchange.com/questions/108212/assertion-error-with-timezone-in-unit-test
https://salesforce.stackexchange.com/questions/249244/system-runas-and-users-time-zone
https://salesforce.stackexchange.com/questions/61242/salesforce-is-there-any-way-to-set-system-time-in-test-class
 
If this information helps, please mark the answer as best. Thank you