This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace JOIEnergy.Domain | |
{ | |
public class ElectricityReadingInterval | |
{ | |
public readonly DateTime Start; | |
public readonly DateTime End; | |
public ElectricityReadingInterval(DateTime start, DateTime end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |