Fixed clock module sunrise/sunset timezone bug (#3070)

Updated sunrise/sunset times to display user-requested timezone rather
than system timezone.

Note: rebase of  #3069 against develop rather than master

Co-authored-by: Veeck <github@veeck.de>
This commit is contained in:
JakeBinney 2023-04-09 01:19:51 -06:00 committed by GitHub
parent 09f117c3d9
commit dee3cd3da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 15 deletions

View File

@ -152,7 +152,7 @@ const formatTime = (config, time) => {
let date = moment(time); let date = moment(time);
if (config.timezone) { if (config.timezone) {
date = moment.tz(config.timezone); date = date.tz(config.timezone);
} }
if (config.timeFormat !== 24) { if (config.timeFormat !== 24) {

View File

@ -114,24 +114,11 @@ describe("Default modules utils tests", () => {
describe("formatTime", () => { describe("formatTime", () => {
const time = new Date(); const time = new Date();
beforeAll(() => {
jest.useFakeTimers();
});
beforeEach(async () => { beforeEach(async () => {
jest.setSystemTime(new Date("2023-01-01 13:13")); time.setHours(13, 13);
});
afterEach(async () => {
jest.setSystemTime(new Date());
});
afterAll(() => {
jest.useRealTimers();
}); });
it("should convert correctly according to the config", () => { it("should convert correctly according to the config", () => {
time.setHours(13, 13);
expect( expect(
formatTime( formatTime(
{ {