Skip to content

Instantly share code, notes, and snippets.

View daicorrea-tw's full-sized avatar

Daiane Correa daicorrea-tw

View GitHub Profile
class UsageInterval
def initialize(date)
day_of_the_week = date.cwday
@end = date - day_of_the_week
@begin = @end - 7
end
def self.usageIntervalFromPreviousWeek date = Date.today
UsageInterval.new date
using System;
namespace JOIEnergy.Domain
{
public class ElectricityReadingInterval
{
public readonly DateTime Start;
public readonly DateTime End;
public ElectricityReadingInterval(DateTime start, DateTime end)
const toUnixTime = (date) => date.getTime() / 1000;
const usageInterval = (start, end) => ({
start: toUnixTime(start),
end: toUnixTime(end)
});
const getSyndayOfTheWeek = (currentDate) => {
const date = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
import datetime
from service.time_converter import iso_format_to_unix_time
DAYS_OF_THE_WEEK = 7
def current_week_start(of = None):
date_to_compare = datetime.datetime.now()
package uk.tw.energy.domain;
import java.time.*;
import java.time.temporal.ChronoUnit;
public class ElectricityReadingInterval {
private final Instant start;
private final Instant end;
final static int A_DAY_IN_SECONDS = 60 * 60 * 24;