Add timezones support
This commit is contained in:
@@ -20,7 +20,7 @@ export class Fetcher {
|
|||||||
*/
|
*/
|
||||||
async fetch(date: Dayjs): Promise<Measurement> {
|
async fetch(date: Dayjs): Promise<Measurement> {
|
||||||
const normalizedDate = date.startOf('day');
|
const normalizedDate = date.startOf('day');
|
||||||
console.log(`Fetching measurements for: ${normalizedDate}`);
|
console.log(`Fetching measurements for: ${normalizedDate.format("YYYY-MM-DD")}`);
|
||||||
|
|
||||||
const monthEnd = normalizedDate.endOf('month');
|
const monthEnd = normalizedDate.endOf('month');
|
||||||
const endDay = monthEnd.isBefore(dayjs(), 'day') ? monthEnd : normalizedDate;
|
const endDay = monthEnd.isBefore(dayjs(), 'day') ? monthEnd : normalizedDate;
|
||||||
|
|||||||
15
src/index.ts
Normal file
15
src/index.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import utc from "dayjs/plugin/utc";
|
||||||
|
import timezone from "dayjs/plugin/timezone";
|
||||||
|
import { parseConfig } from "./config";
|
||||||
|
|
||||||
|
dayjs.extend(utc);
|
||||||
|
dayjs.extend(timezone);
|
||||||
|
|
||||||
|
const config = parseConfig('./config.yaml');
|
||||||
|
|
||||||
|
if (config.timezone) {
|
||||||
|
dayjs.tz.setDefault(config.timezone);
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { TauronConfig } from "./tauron";
|
import { TauronConfig } from "./tauron";
|
||||||
|
|
||||||
export type Config = {
|
export type Config = {
|
||||||
|
timezone?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tauron service configuration
|
* Tauron service configuration
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user