Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [datetime]

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.

1
vote
0answers
24 views

Renting vs. owning comparison calculation

I have working code that compares rental prices and owning costs, given some parameters. It works, but it surely does not look good. I hadn't worked with time-series before and I wonder how I could ...
2
votes
1answer
53 views

Count days from overlapping date periods with Carbon

I had to calculate the total number of days from overlapping date ranges (coming from MySQL in my case) excluding weekends and here is a working version of what I did. I am looking for a cleaner ...
2
votes
2answers
76 views

Reformatting a date from YYYY-MM-DD to MM/DD/YYYY

In this small bit of JavaScript, a date is passed in as YYYY-MM-DD. It's formatted like this to be passed to the backend system. On the front end, we need to ...
-2
votes
3answers
70 views

Translate a day in year to month and day 2nd method

Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. I've already submitted my ...
1
vote
1answer
65 views

Contest Solution: Al Gore Rhythm

The Problem After his brush with the Justice Department over fundraising with Buddhist monks, the Vice President devised a plan to ensure that such activities are carried out in a more discrete ...
1
vote
1answer
74 views

Translate a day in year to month and day

Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. This is what I came up with. ...
6
votes
3answers
593 views

Checking if two time intervals overlap

I have two time intervals i1 and i2, each defined by two values, begin and ...
0
votes
0answers
36 views

Geting data between two specific dates in golang

I have an API which calls a function and that function first will check that in the URL if there is a query string value. Then it will take it and check whether ...
2
votes
3answers
52 views

Display date and/or time

The code below takes an input and based on the input gives out a time, date or both. Please will you review me for this and tell me how I can improve this? By the way, I only started learning python. ...
4
votes
5answers
91 views

Leap year determination using guard clause

I have a function to check the leap year as follows ...
2
votes
1answer
63 views

Java function to format seconds as minutes, hours, days

Anyone know how I write this code shorter, with modulos maybe? I also want to add weeks and years do this code, but it kind of got too long for that. Maybe there is some smart algoritm? Something in a ...
0
votes
0answers
4 views

Generating a playlist from a media collection based on date

This checks my media collection for the current date and generates a playlist to launch. The code is solid but there would be a great need for speed since I have around 27.000 files and it takes a few ...
3
votes
1answer
66 views

Sleep until specified time

It's sometimes useful to pause until a specified time (but inconvenient to use at or the like), so I wrote a tiny script to wait until a user-specified time point ...
4
votes
1answer
36 views

Subtable timestamps in python pandas

I have a dataframe like: ...
2
votes
1answer
60 views

Crontab datetime field pattern parser in Rust

@angus on Unix.SE implemented a tool in C to list upcoming cron jobs in response to a question. I've re-implemented the basic functionality (showing only the next cron job) in Rust, using ...
2
votes
2answers
79 views

React clock component

I'm new to React.js and this code came from 30 Days of React - Day 7. However the given code example wasn't working so I rewrote it myself. My biggest issue here is how to make the component work ...
4
votes
1answer
43 views

Format seconds into the two biggest units of time

I wrote a function to convert seconds into the two biggest units of time and format it into a string. What I mean is that e.g. 134 second would be 02m14s and 3665 ...
2
votes
2answers
52 views

Leap Year game in Java

I created just for practice this leapyear script. What do you think about it? How can I make it more efficient? ...
2
votes
1answer
43 views

Simple Duration calculator using es6 class syntax

I've written a simple script that calculates the distance between two points in time and returns the duration. Example: Start - 11:00, End - 11:45, Duration - 0.75 I wanted to make use of ES6 ...
11
votes
1answer
82 views

CodeVita challenge: forming the latest valid datetime in a year using some given digits

After answering someone's Code Review question, I decided to tackle a sequel: Given an input consisting of 12 non-decreasing single digits separated by commas, form the latest valid date time in a ...
2
votes
2answers
57 views

Parsing date strings, inferring the year such that the date is not in the future

I got this program that I am working on and in it, I got a section that has a try statement and two error except statements. ...
18
votes
8answers
4k views

Program to check if a date is valid or not

I am a novice programmer and am currently learning Python programming by myself through a book. I stumbled upon a question in a chapter and it took me 2 days to figure out a solution for it. Although, ...
2
votes
2answers
72 views

Listing files whose names match a pattern with a date

My directory folderMarket has lots of files with the same name but are tagged with a date string at the end. The date tag can be formatted differently, e.g. "2018-...
7
votes
2answers
307 views

Code Vita: Form the maximum possible time in the HH:MM:SS format using any six of nine given single digits

Problem Description The objective is to form the maximum possible time in the HH:MM:SS format using any six of nine given single digits (not necessarily distinct) Given a set of nine ...
5
votes
3answers
118 views

Displaying the date in MM/DD/YY format

I spent about an hour and a half attempting to complete a problem from W3Resource. Here is what I came up with, which works. How can I shorten it? ...
12
votes
5answers
2k views

Cleaning up date strings in Python

Working from a CSV of about 14.000 lines, I need to match dates in the CSV against some API. I'm reading the CSV using Pandas (for various other reasons). Most often, the date is just a year, i.e. an ...
2
votes
2answers
70 views

Random binary digit generation and file I/O

I've recently made a program which generates a (pseudo) random binary digit (1,0) which is tied to a specific subject to learn for every day of the week. The program generates the digits the first ...
3
votes
1answer
62 views

JavaScript flipping clock

Here are two simple classes - Digit class maintains digit behaviour - primarily flipping animations, and Clock class handles everything that is related to time data. I'm going to use this code for ...
3
votes
1answer
37 views

Stored procedure for sending emails at specified times after license expiration

I need to send email notifications for expired licenses: One Day Before/After Expiration Two Days Before/After Expiration Three Days Before/After Expiration One Week Before/After Expiration Two Weeks ...
1
vote
1answer
43 views

Fuzzy Humanize date using Moment.js for datatable searching

In my JS project, I am using datatable plugin to show data where I have a date column which users can filter/search. In order to help users to search using a logical string such as ...
1
vote
2answers
70 views

Convert minute to time for display

I am new to javaScript, I just coded a method where I can convert a minute to a time in hh:mm AP/PM. I was then displaying the time in a table. I was wondering if there is a better approach to this? ...
4
votes
1answer
96 views

Age in hours calculator

I've written a small script, which calculates hours since the birth. I ask use about how old they are in years, months and day. I show them approximately how many hours they have lived. Below is the ...
3
votes
1answer
281 views

Convert a string in time format to minutes

I am new to C#. I just created a method where I can convert a string with the format HH:MM AM/PM to minutes. I was wondering if there is a better or more effective way to achieve the same result. <...
2
votes
2answers
76 views

Summing payments by year using Java Streams

I'm using 1.8.0_162 version of Java and here is my task about stream framework ...
6
votes
2answers
635 views

Calendar for any given month/year

This is one of my first C++ training project where I created the console application which displays the calendar of any given month. I observed how offset of days (empty places on the calendar) ...
1
vote
1answer
63 views

Get start and end dates and strings

I have a method to get the time parameter, is this code neat, can the return parameter use other data structures? ...
9
votes
6answers
1k views

Loop months between a time span yyyy-mm and yyyy-mm

I'm trying to come up with a more elegant solution for a loop in months that I wrote long time ago in C# 1.1 I use a helper class Month but I'd prefer to get rid of it and make the code shorter and ...
5
votes
1answer
82 views

Calculate the intersections of opening hours

I have a solution but it feels bloated and unclean. How can I clean it up? The second for loop especially does not feel right. I'm trying to calculate the opening ...
22
votes
4answers
544 views

Formatting 3 integers (hours, mins, secs) to `00:00:00`?

I have this at the moment, wondering if there's a cleaner way to do it or if this is already as compact as it gets. ...
5
votes
0answers
80 views

Function which would get the next `n` slots from the current time

I have attended an interview recently and my coding got rejected by the panel. I am new to Python and is mentioning my code below. Please help me improve the code quality or any bug: Question: Given ...
5
votes
1answer
60 views

Pretty print uptime given seconds and omit unnecessary strings

Given an integer number of seconds, return a string which represents in human readable format the number of days/hours/minutes/seconds that are equivalent. ...
7
votes
3answers
155 views

Find the fastest run of each year from a list of running results

Problem Explained: Imagine there is a list of running results of 1000m, like following: ...
4
votes
3answers
63 views

Java class that does calculations between dates

I am writing a simple java class for date calculations, I am aware there are probably better ones out there, but I want to do this myself for practicing purposes. I am planning on expanding this class ...
2
votes
3answers
97 views

Gregorian calendar date

I implemented a Date based on the Gregorian calendar as an exercise. I'm looking mainly for how to make it more readable and easy to test, but any feedback is welcome. ...
6
votes
2answers
167 views

Program to calculate some stats from Facebook messages

I've written a program that parses JSON downloaded from Facebook to calculate some stats from a conversation between two parties. It attemps to count these things: Messages grouped by day of week ...
8
votes
2answers
110 views

Scraping lunar/solar eclipse data with BeautifulSoup

I created a script to scrape this website and gather the eclipse data (date, type, and location): ...
2
votes
0answers
75 views

PostgreSQL: maintaining non-overlapping temporal ranges

I have to store some temporal meta data used primarily in bulk processing of a time-series (sensor measurements). Each value of this meta data is valid for a potentially half-open range of time. ...
5
votes
2answers
266 views

Convert JSON from a webservice to text file

I get list JSON text from a webservice and list_of_columns is predefined, I need the output in that format. I am not sure about few things which are as follows I ...
3
votes
3answers
469 views

Checking if two dates are within 15 minutes of each other

The following code compares two dates and checks if they are within 15 minutes of each other, with a tolerance of a second. All of the test cases below pass with the existing solution. The question is ...