DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day. Use on questions about reviewing code involving date/time logic.

learn more… | top users | synonyms

-5
votes
0answers
19 views

Get final date after skipping weekend and holidays [on hold]

I have 3 modules Master Holidays Cases Master: In master module I have 7 check boxes (Sun,Mon,Tue,Wed,Thu,Fri,Sat). Whatever checkbox is unchecked it means that is weekend day. Ex: Friday, Saturday ...
4
votes
1answer
88 views

ISO 8601 dates & times format into a more human readable format

I wrote from the ground up this small piece of code which transforms dates and times formatted in ISO 8601 format into a more human readable format, client-side. The main goal is that you can create ...
4
votes
1answer
43 views

Getting the three next days

I'm simply getting the 3 future days from an array of objects based on the current day to display for a weather component. This is the first time I've attempted using ES6 and it's features so please ...
3
votes
2answers
36 views

Ensure continuous date range

I have two arrays dates = ["20161010","20161013"] values = [5,3] which represent dates and a view count. To display them in a graph, I also need the values ...
3
votes
1answer
59 views

Blow the fuse if threshold exceeded

While implementing the Retry & Breaker patterns I decided that the Breaker does more then it should so I extracted two responsibilities into their own classes. Here they are. I stripped out the <...
3
votes
3answers
60 views

Constructor for a Time object

I am trying to write a constructor method that takes dd, hh, mm and ...
5
votes
3answers
99 views

Scheduling a task into a period within a day, depending on whether or not it is a weekend

I have a function which needs to detect part of the day depending on whether it's the weekend or not (the weekend affects the lunch time indication). The method is quite long and I'd like to know how ...
0
votes
2answers
65 views

Find every 6 hours from now

I need to find a set of hours, starting from now, every 6 hours. So if now is midnight, I want [ 0, 6, 12, 18 ]. If now is 15h (3pm), I want ...
12
votes
1answer
145 views

How many days to Go?

Here's my first serious attempt at writing Go code. This program counts the number of days until a certain date and displays that in the system tray. To do that, it first reads the target date from ...
6
votes
1answer
95 views

Method to return date ranges of 1 year

I made a method that takes 2 DateTimes as a parameter, a startDate and a stopDate. The ...
4
votes
3answers
136 views
0
votes
0answers
12 views

Select to pick quarter (date)

An includable select to pick the first day of quarter: ...
0
votes
1answer
46 views

Displaying a timetable

The following code displays a Timetable, but the code needs too long finish the whole process. ...
2
votes
1answer
98 views

JavaScript calendar

This is implementation of a Datepicker by our outsource colleagues. I want to get an objective criticism of code style and approaches used. I see: Global variables with popular names Styles inside ...
0
votes
1answer
33 views

Remove dates from a list which have already past and add a buffer of x amount of days

Is there a more efficient/performant way to accomplish this with vanilla js (no libs please) as the looping is slow? Also, how can I make it more flexible, so the HTML option values can vary a little, ...
3
votes
1answer
60 views

Outputting years with no repeated digits

I'm working through a course now, and was tasked with the following: Write a function, no_repeats(year_start, year_end), which takes a range of years and outputs ...
9
votes
3answers
232 views

Verify if meeting datetime ranges overlap in an IEnumerable list of meetings

I have an assignment where I need to find out if any of the meetings in a list of meeting class object have overlapping datetime ranges. What I have so far is this: ...
1
vote
2answers
70 views

Taking some JSON data, converting the date format and calculating a user average

I'm originally a Java developer taking a stab at some Scala development. One of the main reasons I'm posting is because I know that in Scala you can write your code in a Java (OOP) way and it will run ...
3
votes
1answer
30 views

Python date compression

I m making a script to store date information in the smallest size in bits (I don't mind of the actually memory use in the program / runtime) ...
5
votes
4answers
583 views

Day of year calculation method

The exercise I wanted to solve is from here. Copying from that page: ...
4
votes
2answers
72 views

Determining the number of days in a month

Overall logic: determine number of days in a month. Loop through table (wsUploadTable) and increment value if condition is met. Loop to next day in month and repeat....
1
vote
1answer
44 views

Getting client timezone name to use with PHP date_default_timezone_set()

I would like to get the current user's timezone name so it can be used with the PHP date_default_timezone_set(). After looking up a few things I've finally managed to come up with a solution for this. ...
3
votes
2answers
52 views

Find Date in Range

I have a spreadsheet where I control my shift hours. In such spreadsheet I input the date, the start time, time left for lunch, time back to work, end time and sometimes the overtime. After that I ...
8
votes
1answer
138 views

Log sorting program

This is my first ever program written in Rust (after reading the book). It is small tool to sort all lines from stdin according to two criteria. First one is time ...
5
votes
1answer
81 views

Converting a bytearray into an integer

I am working on a program to decode MMS PDU files. They are binary files and I am reading them byte by byte and decoding each header value as I come to it. One header value is the Date, and it's ...
0
votes
1answer
26 views

Take a specified weekday, and check if it falls on the remaining days of the current month

So like the title says, if we are close to the end of the month, we can check if a given weekday (or array of weekdays) will fall from the current day, to the end of the month. If any of the given ...
3
votes
2answers
306 views

Calculate 6 business days

I wrote a little class that will calculate 6 business days from today. The reason it's in a class is because it will be used as a part of a bigger program. I would like a way to refactor this class ...
1
vote
1answer
28 views

Function to search for weekends left in month

I have a function that returns true or false depending upon whether there are any weekend days left in the month. Is there a better/cleaner way that I can write this? ...
1
vote
2answers
54 views

Iterating over a range of dates in a shell script

I have been working on a script that can be used to automatically pull the batch ids that were processed 4 days ago and which need to be processed tomorrow on the server. The batch IDs from 3 days ago ...
0
votes
1answer
45 views

Getting all the dates in a month that do not coincide with a project's dates

I'm creating an array of dates that won't be selectable in a calendar. The following works, although the way I've gone about it is quite long-winded. I was wondering if there is a more elegant way ...
4
votes
2answers
66 views

Comparing dates from sheets

I am looking to increase the speed of this Excel VBA Nested Loop. The loop compares dates from one sheet to a secondary sheet. If they match, I change the border around the cell to highlight it. It ...
2
votes
2answers
63 views

HumanDate for easier date calculations

I need to calculate some dates like yesterday, this week/month, last three/ten days etc. To make it a little bit easier and don't think about the Date weirdness ...
4
votes
1answer
99 views
5
votes
1answer
90 views

Compute Gregorian year from given number of days since day zero

I am working on a batch file for doing date/time maths. One challenge is to determine the (proleptic) Gregorian year from the given number of days that have elapsed since day zero (that is, 1st of ...
4
votes
3answers
98 views

Loop through months (1-12)

I currently have this monstrosity: next_period = (((current_month + tax_period_months)-1) % 12) + 1 I want to get the month that is ...
5
votes
1answer
66 views

Create monthly calendar with number of days and offset (day of week) as user input

I am taking a beginning programming class and have been given the assignment to create a calendar as described in the title. Per the assignment the user entering offset of 0 will begin the calendar ...
5
votes
1answer
33 views

Customized date and time display

A simple reworking of the Bash date command to my own personal liking. Possibly a rather trivial task; I just wanted the date and time to be in the form of: ...
2
votes
0answers
27 views

Function that returns the earliest time point when a worker is allowed to start duty

The task is to provide a function that returns the earliest time point when a worker is allowed to start duty. The function uses two parameters: Time stamp when the rest starts The number of local ...
4
votes
3answers
102 views

Convert length of time to appropriate unit

I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format. I already have code which achieves this, however it'...
4
votes
2answers
109 views

Calculates the number of hours and days left, where the total number of hours is 486

I'm new here and this is my first simple console application that calculates the number of hours left. There's a lot to improve and if you have any suggestions on what things to add or refactor that ...
6
votes
2answers
115 views

Parsing Day Range with Time in Ruby

I need to shorten/simplify this code: ...
3
votes
2answers
119 views

Formatting seconds as days hours minutes seconds

I have the below and it gives me the desired output (ie; 1 day 12:05:33) but it looks overly complicated, is there a more straight forward way of doing this with the least amount of string ...
1
vote
1answer
50 views

Using BigDecimal to validate epoch timestamp in exponential notation

I have some phone records in which epoch time is coming in exponential format like 1467.738871E9. I need to validate those records in which number is not in proper format and drop those records. Right ...
2
votes
1answer
119 views

A clock implemented using Moment.js

This is a POC for a clock using moment.js, eventually I plan to recreate this in Raect.js. Any opimisations or a better way to do it? ...
3
votes
2answers
97 views

Simple Input Text Analysis

I've started learning java. I've written a small program I've done in C before. It's simple input analysis. If there is number, program checks if number is prime. Then write number: (value of input ...
1
vote
2answers
72 views

Comparing adjacent time stamps

I have this code which compares two adjacent time stamps. If they are less than 15 min apart, it adds a new time stamp (row) in between with the new time stamp equal to the previous time + 15 min and ...
3
votes
5answers
107 views

Selectable date filters

I created a simple app with Backbone and Marionette. In a view I created an onRender function. I created a page that displays a Report with a date filter, using a select tag and affect to an input ...
0
votes
1answer
86 views

Calculate the total cost between two dates based on a weighted time interval scheme

Consider we have to pay the usage of a machine with the following hourly cost: 00:00 - 01:00 --> $4 per hour 01:00 - 05:00 --> $1 per hour 05:00 - 22:00 --> $2 per hour 22:00 - 24:00 --> $3 per hour ...
8
votes
0answers
71 views

Parse RRULE icalendar entries

I'm using the icalendar module to parse (google) calendar entries and the dateutil.rrule module to deal with recurring events. ...
1
vote
0answers
62 views

Correcting time in DST gap using Joda Time

We have a class which acts as a time interval, containing a LocalDate and two counts of minutes since midnight. One of the methods on this class converts these values into two DateTimes. Since ...