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.

-4
votes
0answers
13 views

Get Every Week's Start and End Date from Series End Date Range Linq [closed]

I have an application where a user will give input Start Date, End Date and Series End Date. Example StartDate= 02/12/2019 EndDate = 03/16/2019 SeriesEndDate= 12/31/2025 I want to get start and ...
1
vote
0answers
35 views

PHP project with Google Calendar API

I'm playing with a simple (for now) project in PHP with Google Calendar API. I have posted the code here in order to improve my programming style about whatever you think it's worth suggesting. Thank ...
0
votes
1answer
15 views

Generate n appointments in the next m months

I work with an API where I need to write code to generate n appointment dates in the coming m months (from today). For the purpose, I write a Random date generator class provided. One condition is I ...
2
votes
1answer
46 views

Calendar holidays to XML

We are writing program which makes XML file which is a calendar with all free days in Poland (Saturdays, Sundays, and all hollidays). We tried to write this code as readable as possible so probably no ...
0
votes
0answers
23 views

Laravel working with dynamic start and end dates to grab some data

So, to start off, the below code does work, but it feels like a newbie solution to me, and if I ever need to come back to this code, I will have no idea what I was thinking. I have a table called <...
2
votes
0answers
20 views

Get local datetime from UTC time

One of the app is inserting date in UTC format (column CreateDate). When reporting from this table, I used a difference in hours between the inbuilt ...
1
vote
3answers
53 views

Change state depending on holidays, weekends or hour of day

I'm writing a script that's changing the background color depending on hour of day, if it is a weekend or if it is a Swedish holiday. I have a functional script and as I want to improve my programming ...
5
votes
1answer
32 views

Scheduled file sorting with Ruby

I have a script running as an hourly cron job. It finds all screenshots on the Desktop and moves them to directories sorted by year/month/day. On MacOS, screenshots are automatically saved to the ...
1
vote
0answers
43 views

Retrieving date and time from Datepicker and Timepicker and then converting it to milliseconds

I currently have an Android Activity that allows the users to select the startDate, endDate, ...
0
votes
1answer
28 views

Pure JS countdown clock not converting millisecond time correctly [closed]

I have a semisimple pure js countdown clock that I am having trouble converting the millisecond time correctly. Here is a working Plunker (besides the date counter) It Should only be 38 days instead ...
2
votes
2answers
91 views

Calculator to add time intervals

I have written a little program that calculates the time by given strings. A time string in the context of this program consists of a number and a following letter that can be s, m, h, or d. You can ...
2
votes
0answers
66 views

Event Calendar in JS, CSS, and HTML

I repeated a lot of code here and I'm trying to use more ES6 but I'm not sure where I should have used it in my code. I'd appreciate any input on where I could improve. GitHub ...
3
votes
1answer
30 views

Iterate between dates and INSERT values in a performant way

I have created a query that populates a datapoint with random values. The logic is simple: Iterate between the START and END dates and INSERT random values. I want from this query to be very ...
1
vote
1answer
77 views

Parsing displayed month/year for calendar

I have a 6 x 7 grid for a calendar = 42 DateTimes. I'm trying to display the displayed month/year at the top of the calendar. If there are 3 months displayed, I ...
2
votes
1answer
39 views

Extracting and reformatting dates from text

The task is find by pattern d--m--y---- all occurrences in text, reformat it to yyyy:mm:dd and print it separately from initial text. Actually I done all except formatting. And even in my written ...
1
vote
1answer
47 views

Calculate the number of days passed from a given year

I have this code for calculating the number of days passed from a given year: ...
2
votes
2answers
58 views

Python date formatter

I'd like to find the best way to format date to YYYY, YYYYMM or YYYYMMDD. Here is what I've got so far: ...
2
votes
3answers
65 views

Printing a monthly calendar on console

This is an implementation of mine to an exercise found in the book Core Java SE 9 for the Impatient. Goal is basically to print a monthly calendar by accepting month and year information from the user....
1
vote
1answer
65 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 ...
3
votes
1answer
277 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
142 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
73 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
68 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
82 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
1k views

Checking if two time intervals overlap

I have two time intervals i1 and i2, each defined by two values, begin and ...
2
votes
3answers
57 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
99 views

Leap year determination using guard clause

I have a function to check the leap year as follows ...
2
votes
1answer
78 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 ...
3
votes
2answers
126 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
52 views

Subtable timestamps in python pandas

I have a dataframe like: ...
2
votes
1answer
66 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
80 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
53 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
56 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
54 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
89 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
59 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. ...
19
votes
8answers
6k 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
81 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
442 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
120 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
3k 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
75 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
70 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
66 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
72 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
102 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
699 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. <...