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
1answer
48 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
44 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
42 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
55 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: ...
6
votes
1answer
56 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". ...
4
votes
1answer
52 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 ...
5
votes
2answers
91 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 ...
8
votes
5answers
327 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 ...
-5
votes
1answer
66 views

Date Range Tree

...
4
votes
4answers
261 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 ...
1
vote
0answers
32 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
44 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
64 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
44 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
82 views

Naming request for a class to return 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 ...
11
votes
4answers
479 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 ...
4
votes
2answers
47 views

Conditionals for time specific data (SQL style)

I was inspired by this question from @AndyRoid to try and come up with some fast and accurate datetime calculations that didn't involve complex if/else statements. My hammer tool of choice was ...
7
votes
6answers
422 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
2
votes
3answers
171 views

Find number of whole weeks between months in the same year

I wrote a class to return the number of whole weeks between months in the same year. I need suggestions on my code. ...
3
votes
1answer
38 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
0
votes
0answers
19 views

Dynamic/Global Business Days Calculation

I have a problem in that I need a formula which calculates business days around the world. For example, in the UK we have 5 day weeks, but in the Middle East they have 6 day weeks. Also, perhaps we ...
4
votes
1answer
68 views

Game boot to some operations every second

I am building game, like Ogame, or Ikariam where you can play with other users in real-time. You train some soldiers, and build some vehicles or buildings. Every building or vehicle has some level. If ...
7
votes
3answers
184 views

Colorizing Excel cells with a date range filter

In a table there is a number of column (chambre) and a number of row (alveole). If these matches in a list in an other sheet then it checks if it the date is between two dates on that second sheets. ...
3
votes
1answer
55 views

Projecting future positions

My code takes a starting position (which must be completed) and a list of updates (each element of which is optional). It then projects future positions, using the appropriate value from each update, ...
4
votes
2answers
98 views

Calculate amount of seconds from user birth date to beginning of current year

I'm trying to make a program where user will put in his birth date in DD/MM/YYYY form and he will get back amount of seconds between his birth day and 01/01/2015. It counts with fact that different ...
2
votes
1answer
73 views

Get Elapsed Time as Human Friendly String

In lieu with several other Facebook-esque concepts I am trying to replicate, this working code will take the span of time from a given date to now, and try to convert it into the most convenient ...
2
votes
2answers
74 views

Getting hours during the day

I have this method that returns an array of all the hours for the past 24 hours, ex: if the current time is 3:24pm it looks like @[3pm,4pm...12am,1am...2pm,3pm]; ...
6
votes
1answer
59 views

Find the next 8 dates that are Mondays (exclusive of today)

Any thoughts on improving this method of finding the next 8 Mondays not including today? ...
2
votes
0answers
47 views

An implementation of `ago()` in PHP

Here is my code for the string ago(int timestamp) function: Bitbucket snippet ...
2
votes
1answer
35 views

Running alarms in python

My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. ...
2
votes
2answers
102 views

Build a time struct for current time in UTC

I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct ...
2
votes
1answer
49 views

Net health monitoring

This is a little net health monitoring project I made in NodeJS. It pings google every second and stores the result (true/false) along with the date in a database (MongoDB). I've collected enough ...
3
votes
1answer
91 views

Extracting opening and closing times for each day of the week

I have these two methods: ...
11
votes
2answers
102 views

Prorated refund calculator

I wrote this little piece of script for my workplace (insurance, etc.) to help our admins, as a light and simple file I can just email to my colleagues. The purpose of it is to calculate a prorated ...
3
votes
1answer
134 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 ...
3
votes
2answers
84 views

Store open days and times

Currently I'm developing my business entities. I feel that the structure is a tad cumbersome. What I mean is that a store on a particular day can have different open and closing times. So it's not ...
4
votes
3answers
62 views

Checking dates against a .properties file

I am writing a script that will check the set values against a .properties file and I am just wondering if there is any nicer way to write what I have here. ...
2
votes
2answers
62 views

Countdown to multiple update times each day

I'm creating an update function to show my users when the next update will be available. I'm using the jQuery countdown plugin to show the time. What is a more efficient way to write this? ...
2
votes
1answer
38 views

Random date gen class. Returns a tuple of a start date and end date

Just interested in any comments about the way the code is written. I am very new to python and programming. I did think about a func with a generator, but thought this approach was better. ...
2
votes
1answer
72 views

Determining the number of days from today

Today I've got a pretty simple snippet to be reviewed. The function is extremely simple, as all it does is retrieve some entities from Core Data and then compares the ...
0
votes
3answers
89 views

convertToHHMM function

Can someone help me make a more elegant solution to this function? ...
7
votes
3answers
158 views

Simple greeting program based with timezone offset

I made a simple set of functions that returns a greeting based on the current time, the user's timezone offset, and the user's level. For context I wrote this as a part of a larger chat bot ...
5
votes
0answers
51 views

Expressing Rebol Dates in BNF

I'm looking to define the Rebol date format in BNF notation (as adapted for Rebol Parse). I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
4
votes
1answer
78 views

Expressing Rebol Dates in EBNF

I'm looking to define the Rebol date format in EBNF notation. I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
3
votes
2answers
131 views

Implementing a Yearmonth class

Recently I wrote a program that was required to handle year and month data and so I wrote this class to encapsulate that handling. What I needed was a way to initialize the ...
2
votes
1answer
67 views

Convert list of UTC to Current TimeZone

I found myself with a list of UTC timestamps and wanted to convert them into the local time zone. Using this web post as a starting point, I modified the script to grab a text file containing UTC ...
5
votes
3answers
327 views

Model interval inclusiveness in C#

This is my first attempt to model a day's time interval and the fact that the start and end are either inclusive or not: ...
6
votes
1answer
179 views

LiveDate version 2

LiveDate has the ability to display the current date either by asynchronously fetching the time from a server or by just using the client system date. It's only as ...
2
votes
1answer
125 views

Generating Calendar month information using JavaScript

I am using the below function to set month information on context passed. It is working fine, but please review it and let me know if there are any potential flaws or any improvements in this code. ...