DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

1
vote
0answers
9 views

Finding the date from “2nd Friday of X month”-style input

I've been working through some puzzles from exercism.io. Current puzzle asks me to return a date() from input that essentially says "The 3rd Friday of December" or ...
0
votes
0answers
30 views

Sunrise calculator [on hold]

I'm taking a stab at learning Swift, and thought I'd ask for a code review. Basically, can you look at the code and tell me whether where the novice errors are, and what I should be doing instead? ...
2
votes
1answer
35 views

java.sql.Timestamps: There's gotta be an easier way

I have a function that counts how many "assists" a team performs during the course of their day. The way I've written it feels bulky and inefficient using GregorianCalendar. Basically, the ...
2
votes
3answers
62 views

Seasons by month and day

Write a program reads two integers representing a month and day and prints the season for that month and day. Assume that months are specified as an integer between 1 and 12 (1 for January, 2 for ...
3
votes
1answer
31 views

Returning two dates based on input

I created a function that will return 2 dates that depend on an input parameter. When the parameter is: 1 - return start date of current week and end date of current week 2 - return start date of ...
2
votes
1answer
32 views

Schedule conflicts approximating program

This small application is used to approximate conflicts in a schedule. Using a minimal time span of 30 minutes in my example, the application should be able to figure if there's a conflict in +/- 30 ...
7
votes
5answers
480 views

Normalizing `DateTime` values to strings

I have this as part of a project to normalize DateTime values to more readable strings, localized to the relative time in the past that they happened. It allows ...
6
votes
2answers
68 views

Project Euler #19: Counting Sundays in the 20th century using Pandas

Project Euler #19 asks: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? I'm hoping I wasn't too off course from the spirit of the ...
7
votes
1answer
63 views

C++ calendar printer

I was at CppCon last week and watched a clever talk about using ranges and calendars. This is just me trying to play around with the new technology. Step 1: dump out a calendar. Usage: ...
4
votes
2answers
74 views

The Badge Bot 9000

Because I'm both lazy and wanting to mess around more with time management and Ruby, I thought it would be fun to create a simple script that opens Code Review once every day to go towards the daily ...
5
votes
1answer
53 views

Working Days DateDiff function

I have a calendar table with a record for every date I need to care about (i.e. 365 records per year), with various meta-information about each date, including the weekday, the fiscal calendar week, ...
6
votes
3answers
137 views

Revealing store sales based on time

I am delving into trying to write some JavaScript code. I understand the basics, (the very basics...) enough that I have been able to write the following and it works. However, my knowledge doesn't ...
7
votes
2answers
459 views

Countdown clock in Python

This project is from the subreddit for beginner Python projects: The goal of the project is to create a program that allows the user to choose a time and date, and then prints out a message at ...
0
votes
1answer
53 views

Designing a generic C++1z class [closed]

I'm designing a generic interface for a MessageEntry class for a .h file. I'm looking for guidance on form and terminology (would I call this an interface/template/generic class?): ...
5
votes
2answers
417 views

Program that tells if a date is valid in C

I'm reading a book about C programming, at the end of each chapter it has some training exercise and one of them was to make a program that tells if a date is valid or not, the code below is what I ...
2
votes
1answer
27 views

Aggregate sum by month

I have JSON data: var data = [ { dat: 'timestamp', val: 10 }, { dat: 'timestamp', val: 20}, (...)] Data contains objects with timestamp and value, can be more ...
7
votes
2answers
44 views

Printing the days of the week for every day this year

@chux pointed out that my attempted solution contained several problems. Since I screwed that up so badly, I figure that I should put my revised solution up for review. ...
2
votes
0answers
38 views

Adding 1 to JavaScript Date while binding using knockoutjs [duplicate]

I am using knockoutjs to bind some values in an array. For each entry in the array I have a date value TimeByDay that I bind like this: ...
1
vote
0answers
84 views
3
votes
3answers
55 views

Displaying days of the week for all of 2015

This program is supposed to determine the day of the week for 2015. Could someone tell me how I could shorten my code? ...
3
votes
3answers
606 views

Convert a date string to a DateTime object in C#

I was just wondering if my code contains defects or if there was a more efficient or general way to convert string to DateTime object. In the input, I have a string ...
10
votes
5answers
421 views

Birthday validity-checking

I have written code to check any birthday input's validity. As I am new in programming, and after going through several debugging steps, the code became very ugly. ...
7
votes
1answer
86 views

Small Calendar “Widget”

I have been working on a calendar widget for the past hour or so. I wonder if it could be compacted any more than it already is (ignoring whitespace). ...
12
votes
2answers
141 views

Mengenlehreuhr in Python

Telling the time based on the "set theory principle", the Mengenlehreuhr consists of 24 lights which are divided into one circular blinking yellow light on top to denote the seconds, two top ...
-1
votes
2answers
63 views

Extracting a date and time from a log file

I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of ...
7
votes
5answers
540 views

Return Nth Weekday of Month

My goal is to obtain the nth weekday of a given month. Parameters are a date from a given month and the nth weekday I'm trying to obtain. It returns the Nth Weekday of the month if it exist and ...
1
vote
0answers
65 views

Updating datetime fields from UTC to local time zone

I have created an SQL query to update datetime fields from UTC to local time zone. Can someone review this? ...
4
votes
0answers
91 views

Datepickers for departure and return dates

I have to two datepickers. I want achieve a following functionality: when return date cannot be selected before departure and departure cannot be after return date. Mainly I am interested in ...
4
votes
1answer
44 views

Deleting most recent files by parsing filename

I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different ...
4
votes
2answers
138 views

Calculating German common holidays

I wrote a simple dll which is able to calculate all common holidays, but, I would like to optimize the code in readability and flexibility. Federal state ...
5
votes
2answers
61 views

Writing a utility class for converting between datetime and timestamp

I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 ...
2
votes
2answers
83 views

Date formatters, lazily instantiated once

I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code ...
4
votes
1answer
286 views

WPF DateTimePicker user control

I've created a UserControl that should act as a control inside a Window: XAML: ...
1
vote
1answer
55 views

Countdown script

I made a script in JavaScript to calculate how long it takes until a certain date. Do you find it user-friendly enough? Is the code correct? ...
1
vote
2answers
105 views

Listing every date between two dates in input fields

Using the following HTML: <input type="date" value="2015-07-26" name="startdate"> <input type="date" value="2015-07-29" name="enddate"> First, the JS ...
2
votes
3answers
56 views

Transforming data from an array of objects to a nested array of objects

I have an array of objects where each object has a datetime key/value pair: ...
2
votes
4answers
59 views

Parsing time if valid

I need to parse only valid timestamp formats: Hours followed by minutes followed by seconds: t=1h2m3s Minutes followed by seconds: ...
7
votes
1answer
96 views

Bucketizing time (e.g., 4 min => 0-5 min)

Specification: Given a string (e.g., the content of an article), print the estimated reading time by bucketizing time into increasingly large chunks in the form "5-10 min" or "48 min-2 hr". ...
5
votes
1answer
64 views

How much time is left?

rags-to-riches of Convert seconds to hours, minutes and seconds. In that question, BigDecimal was chosen to be the model class, which doesn't seem like a right fit ...
8
votes
3answers
147 views

Every year is like a loop. A nasty, nested one

Quite a little while ago, I wrote a VBA macro to generate fiscal calendar date records. That macro did the job all this time, but I needed to be able to generate fiscal years from an ETL overnight ...
9
votes
5answers
355 views

Prorated Refund Calculator (v2)

This is a follow-up question to original Prorated Refund Calculator. Here is the summary of the changes I made since last, thanks to the good answers and some study of my own. Did away with ...
-6
votes
1answer
82 views

Date Range Tree

...
4
votes
4answers
315 views

Alarm clock printing

I know there must be an easier way to write this but I'm stuck in over-complicating mindset instead of just following the Zen of Python. Please help me simplify this. Given a day of the week ...
4
votes
5answers
1k views

Leap year check in Java

I'm looking for 3 different answers: Using Java predefined functions Converting from string to number Without the above two (any other types of answers are also welcome) I am looking for improving ...
4
votes
1answer
51 views
1
vote
1answer
44 views

Get Next and Previous “Load Day”

I keep looking at this trying to figure if there's a better way. All three functions work, but I wanted to get some insights and ideas from others. IsLoadDay ...
1
vote
3answers
63 views

Date composition from day, month and year input

I need to concatenate 3 input fields into a string which is formatted as a date dd-mm-yyyy, using type="date" or ...
4
votes
2answers
66 views

Getting all the UTC “day stamps” between 2 dates

I need to get every UTC day stamp in yyyy-MM-dd format (e.g. "2015-07-02") between any two arbitrary Date fields. My first attempt is this: ...
0
votes
3answers
47 views

Rewriting hours

I am just trying to rewrite hours; say 1:24PM, if 24 > 30 then it is 2PM, otherwise it is 1PM. I really doubt that I am doing it right, first I am sure it looks so amateur, second I am not sure if it ...
3
votes
1answer
99 views

Class for returning a different value every so often

I have a class that I'm trying to determine a good name for. I don't know if this concept comes up a lot in programming or not, but I'm wondering if I can get some suggestions for a good name for the ...