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.

Filter by
Sorted by
Tagged with
-3
votes
0answers
19 views

Parsing DateTime with timezone [closed]

I am facing difficulty in parsing a DateTime with the structure of time zone: I am trying to parse it this way: ...
6
votes
2answers
7k 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 ...
10
votes
1answer
611 views

Printing the date of any day of the week as it occurs between two set dates

This a block of code taken from a program I am working on that creates multiple files. This part of the code is to create files and sort them by date by appending the date to the file name. User ...
2
votes
1answer
38 views

PowerShell - calculate occurences of Friday the 13th between (including) two given years with builtin and without builtin

It's me again, talented programming beginner fast-learner, so I have overcomed yet another self-imposed programming challenge, I have developped two algorithms to calculate occurrences of Friday the ...
1
vote
1answer
33 views

JavaScript date format string to php date format string convert

Please find the following scenario, I've dynamic JS date format string from API but I am looking for the best way to convert the format that accepts in PHP date format. For now, I wrote it my own way ...
0
votes
1answer
40 views

DateTime Extension for entering historical dates, i.e. birthdays

This class is intended to fulfill these requirements: Output in Y-m-d H:i:s format Allow dates to be entered as m-d-Y or m-d-y Complain if an invalid birthdate is entered (i.e., in the future or ...
4
votes
2answers
148 views

Java - General purpose String to LocalDateTime parser

I have a couple of general purpose LocalDateTime parser methods I wrote to handle Dates flowing between a number of legacy XML based processing pipelines over to a modern Spring Boot, Mongo ...
6
votes
2answers
410 views

Checking if an array of dates are within a date range

I created a dates_in_range() function which checks if all of the dates passed to it ($dates array) are within ...
5
votes
3answers
57k views

Printing the month name for the month number

This program asks a user to input any number equal to or between 1-12. It then converts the number to a message that will be printed (Copy the program to see it yourself). Is there a way to make the ...
2
votes
1answer
24 views

Input any time, output timezones that are currently that time

I made a program that will take in a time and a weekday, and return which parts of the world are at times closest to the one specified. Part of the program focuses on extracting a date and country out ...
13
votes
4answers
10k views

Compute the day of the year

I am new to programming. I saw this Java code with a lot of if-else statements that is copied below. People say that such a code ...
2
votes
0answers
67 views

Creating calendar - Speeding up PHP script

I'm working on a calendar for my office. Every people has his own column and there is a line for every day. There are some periodic date, where, for example, given people have to be working on the ...
2
votes
1answer
40 views

JavaScript function for the get the formatted date of tomorrow

I need a JavaScript-function which always computes the date of the next day. Then returns the date as a string, formatted in the way: dd.mm.yyyy I wrote this code: ...
5
votes
3answers
4k views

Showing “open” or “closed” based on the current time

I'm using this code to have a site show either "Open" or "Closed" depending on what the current time is. I'm a junior developer and I want to show this to my boss but one of the ...
9
votes
4answers
594 views

Calculating parking fees, given start and end timestamps

Since I have just started Javascript, I am trying to solve a few problems and improve myself. I encountered such a question. I tried to do everything step by step from the question, but I do not think ...
7
votes
2answers
3k 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 ...
2
votes
3answers
6k views

HackerRank Time Conversion solution

The challenge (PDF) is to convert a time from 12-hour format (hh:mm:ssAM or hh:mm:ssPM) to 24-hour format. This is my solution, ...
1
vote
0answers
51 views

PowerShell - Calculating date difference between two given dates in days without builtin and with builtin

The title says it all, I have written two scripts to calculate dates to test my abilities in programming, one from scratch, without [DateTime], New-TimeSpan and even [math]::Ceiling, and it's really ...
3
votes
1answer
35 views

Calculating difference between cached period and requested

There is a remote resource containing datasets arranged by time, data is static and doesnt change. Whenever we are going to fetch anything from there we will be saving it in our cache. User might ...
3
votes
1answer
227 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 ...
2
votes
1answer
55 views

Countdown click in JavaScript

I did a small countdown clock challenge in JavaScript. Please review it, thanks. ...
3
votes
1answer
60 views

Does this R code look ok to expand out to other sites?

I'm after some constructive criticism on my code and maybe some ways to simplify before I expand it to include other sites. I am new to R and coding and have been working on this problem for weeks now....
3
votes
2answers
68 views

Calculate age given the birth date in the format YYYYMMDD

Here is method to calculate age given the birth date in the format YYYYMMDD. ...
2
votes
1answer
90 views

DateTime range splitting algorithm

I have the algorithm which splits DateTime range into multiple ranges based on night time range. For example: Night start: 22:00, Night end: 06:00 Start time: 2020-10-26 21:00:00 End time: 2020-10-27 ...
6
votes
4answers
1k views

Convert minutes portion of time to decimal

I am making an hours calculator app. It takes a start time, end time and time taken for lunch. For the start and end time it takes a four-digit hh:mm time. For example: 10:20. I have made a function ...
2
votes
2answers
466 views

Checking if the access token is valid or expired

Basically, the server gives me a token object. I am planning to check the token on the client if it is expired/valid before ...
3
votes
1answer
50 views

ways to code for better speed of processing date comparisions / slicing in python

I wrote the below code to convert a long data frame containing start and end date event spans into a daily df with rows for each day: output: ...
2
votes
2answers
228 views

Date Detection with Python RegEx

its a practice project from "Automate the Boring stuff with Python" book. i am an intermediate level Python programmer and i tried to solve this problem with less code as possible. This code ...
12
votes
6answers
8k views

Python Code for List of Month Names starting with current month

I am looking for a cleaner, more pythonic way to get a list of the name of the months starting with the current month and ending 12 months later. For example, it's December so my list should be <...
3
votes
0answers
52 views

Calculate age from birthday in C#

For a project I'm working on, I need to calculate the age of users based on their birthday (which is a DateTime object). with a few requirements: the output must be in french (the entire project is ...
-2
votes
1answer
43 views

what is the best practice concerning opening CSV files in python [closed]

I am looking for the best way to save regular data from a series of sensors to a CSV file. the program will be reading every sensor once a minute 24/7 and needs to report the results to a CSV file ...
4
votes
1answer
2k views
2
votes
1answer
43 views

Using datetime to obtain the time of the next lecture

Often before the lecture starts, and occasionally in the break I like to display a timer with a countdown until the lectures starts/ resumes while playing some lofi-hip hop in the background. While ...
2
votes
3answers
3k views

Script to activate an alarm at a time in the future

I am making a flashlight plugin for macOS. Here is the main code, plugin.py, the method results gets called first and is passed ...
3
votes
2answers
312 views

Javascript check if server time is greater than or less than 9am EST

I offer same day shipping if the user places an order before 9AM ET. If they place the order after 9AM, same day shipping is unavailable. My server is using UTC time so I need to check if the time is ...
4
votes
1answer
24 views

Creating formatted “[time] [unit] ago” messages from a seconds value

I have this function which calculates how many seconds, mins, hours etc ago a specific time string was. However, the way I have done it consists of a massive if statement block, and it goes through ...
9
votes
2answers
5k views

Age verification module in Python

I wrote an age verification module in Python 2.5 . How can I improve on current_year? import time perhaps? ...
5
votes
3answers
3k views

Implementing a week schedule class in C#

Requirements A week schedule class .NET framework has DateTime struct, but I want a general week schedule class that involves day of week instead of date. For example, a shop has open hours from 9:...
6
votes
3answers
165 views

C date information program

Inspired by a section from K&R C (exercises 5-8 and 5-9), I decided to write a program that would take a date numerous numeric forms, all based around DD/MM/YYYY, and from the given date determine ...
4
votes
1answer
8k views

XMLGregorianCalendar to LocalDateTime

From some generated code I get a javax.xml.datatype.XMLGregorianCalendar and I want to convert it to a LocalDateTime without any ...
5
votes
3answers
4k views

Efficient human readable timedelta

I wanted to write a human readable datetime.timedelta that can be used in log files. Eg, "Report issued 1 hour, 44 minutes, 20 seconds ago" I noticed that casting a timedelta to str() generates ...
1
vote
1answer
34 views

Check that elements in list follow a specified date-format schema and are not null/na/nan [closed]

I'm practicing some data-analysis and I'm currently checking the integrity of my data. The elements that do not follow my date-schema, should be funneled to a new separate list so I can work on ...
4
votes
1answer
114 views

Script for generating a report in Google-Spreadsheets. Looks for various values to check and count

It all works exactly as it should. It finds data from today, finds unique emails and puts them in an array. I then check the data again from today, against the emails to total up different values. ...
5
votes
2answers
315 views

Removing points from slow riders

I have a CSV like the following. ...
1
vote
1answer
68 views

Working out how many hours worked after a certain time

I am working on some custom rules in a time managment system and need to know how many hours in a shift have been before a certain time (19:00pm) and how many hours after. Shifts can start in the ...
4
votes
1answer
56 views

Apply additions on a base array based on date ranges

please roast my code, I hope this is the good place to look for some advice on where I can improve. Problem definition: Apply modifications on values depending on date ranges. Data: Base array - ...
3
votes
1answer
3k views

Counting Monday and Friday from a Date Range

How can I get Monday and Friday from a date range (start and end date)? Example: startdate - 03/24/2014 enddate - 04/01/2014 Result should be: Monday - 2 Friday - 2 I tried this code: ...
2
votes
1answer
78 views

Parse org-mode clocktable CSVs into time sheets

For my student job, I have been logging work times with the org-mode in emacs for quite some time. Now since I can only work from remote, I figured it would be nice ...
4
votes
3answers
1k views

Leap year check in Haskell, using pattern matching or bind operator

One of the first Haskell puzzles on http://exercism.io/ is to implement a leap year check. I've done this twice. Using pattern matching: ...
2
votes
0answers
43 views

Fastest conversion of ISO 8601 string into javascript Date object

On StackOverflow I got a great answer to a question I had about creating a Date object from an ISO 8601 string with the ability to reposition into local time. From there I wanted to see if I could ...

1
2 3 4 5
20